diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 5272e554..c3e01e1e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.52.2" + ".": "0.53.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 037b2232..f2253470 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 103 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-95a3d7780935a38e0cf076d4ad2d68bd1a5641bced8398d972db2e92751d364a.yml openapi_spec_hash: 9ebe818c4ad4f2d9c4e473b5192d7544 -config_hash: ec4f1e02d3528e3a93a73e33bca17c2a +config_hash: 3dc5bc1df028fc7301fb2ada9846f038 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7719043b..b1a9f7ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 0.53.0 (2025-04-02) + +Full Changelog: [v0.52.2...v0.53.0](https://github.com/orbcorp/orb-java/compare/v0.52.2...v0.53.0) + +### Features + +* **client:** add enum validation method ([d6fdaa3](https://github.com/orbcorp/orb-java/commit/d6fdaa34309a8c1bcc4f2bd84beaae587f3a3e9d)) +* **client:** make union deserialization more robust ([#379](https://github.com/orbcorp/orb-java/issues/379)) ([d6fdaa3](https://github.com/orbcorp/orb-java/commit/d6fdaa34309a8c1bcc4f2bd84beaae587f3a3e9d)) + + +### Chores + +* **client:** remove unnecessary json state from some query param classes ([d6fdaa3](https://github.com/orbcorp/orb-java/commit/d6fdaa34309a8c1bcc4f2bd84beaae587f3a3e9d)) +* **internal:** add invalid json deserialization tests ([d6fdaa3](https://github.com/orbcorp/orb-java/commit/d6fdaa34309a8c1bcc4f2bd84beaae587f3a3e9d)) +* **internal:** add json roundtripping tests ([d6fdaa3](https://github.com/orbcorp/orb-java/commit/d6fdaa34309a8c1bcc4f2bd84beaae587f3a3e9d)) +* **internal:** codegen related update ([#381](https://github.com/orbcorp/orb-java/issues/381)) ([1373dc9](https://github.com/orbcorp/orb-java/commit/1373dc9c246351e40eb442e4af9af81c1b8cb881)) + ## 0.52.2 (2025-04-01) Full Changelog: [v0.52.1...v0.52.2](https://github.com/orbcorp/orb-java/compare/v0.52.1...v0.52.2) diff --git a/README.md b/README.md index 2898dac9..fe7a91e1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.52.2) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.53.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-java:0.52.2") +implementation("com.withorb.api:orb-java:0.53.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:0.52.2") com.withorb.api orb-java - 0.52.2 + 0.53.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 153bd1ba..c113fc72 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ allprojects { group = "com.withorb.api" - version = "0.52.2" // x-release-please-version + version = "0.53.0" // x-release-please-version } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/BaseDeserializer.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/BaseDeserializer.kt index 2a73d238..4735d626 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/BaseDeserializer.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/BaseDeserializer.kt @@ -7,11 +7,9 @@ import com.fasterxml.jackson.databind.BeanProperty import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.JavaType import com.fasterxml.jackson.databind.JsonDeserializer -import com.fasterxml.jackson.databind.JsonMappingException import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer -import com.withorb.api.errors.OrbInvalidDataException import kotlin.reflect.KClass abstract class BaseDeserializer(type: KClass) : @@ -30,38 +28,17 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.deserialize(node: JsonNode, type: TypeReference): T = + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = try { readValue(treeAsTokens(node), type) } catch (e: Exception) { - throw OrbInvalidDataException("Error deserializing", e) - } - - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: TypeReference, - validate: (T) -> Unit = {}, - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { null } - } - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: JavaType, - validate: (T) -> Unit = {}, - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt index 8710064b..df2451e5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt @@ -4,12 +4,16 @@ package com.withorb.api.core import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.MapperFeature import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.cfg.CoercionAction import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.databind.type.LogicalType @@ -17,13 +21,23 @@ import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.kotlinModule import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField fun jsonMapper(): JsonMapper = JsonMapper.builder() .addModule(kotlinModule()) .addModule(Jdk8Module()) .addModule(JavaTimeModule()) - .addModule(SimpleModule().addSerializer(InputStreamJsonSerializer)) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) .withCoercionConfig(LogicalType.Boolean) { it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) @@ -91,7 +105,10 @@ fun jsonMapper(): JsonMapper = .disable(MapperFeature.AUTO_DETECT_SETTERS) .build() -private object InputStreamJsonSerializer : BaseSerializer(InputStream::class) { +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer override fun serialize( value: InputStream?, @@ -105,3 +122,46 @@ private object InputStreamJsonSerializer : BaseSerializer(InputStre } } } + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt index 9cf3ba5a..e0ad480d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt @@ -26,6 +26,34 @@ internal fun , V> SortedMap.toImmutable(): SortedMap> Sequence.allMaxBy(selector: (T) -> R): List { + var maxValue: R? = null + val maxElements = mutableListOf() + + val iterator = iterator() + while (iterator.hasNext()) { + val element = iterator.next() + val value = selector(element) + if (maxValue == null || value > maxValue) { + maxValue = value + maxElements.clear() + maxElements.add(element) + } else if (value == maxValue) { + maxElements.add(element) + } + } + + return maxElements +} + /** * Returns whether [this] is equal to [other]. * diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt index 981f9010..ca2be828 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -518,10 +518,36 @@ private constructor( plan().ifPresent { it.validate() } subscription().ifPresent { it.validate() } thresholds().ifPresent { it.forEach { it.validate() } } - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (enabled.asKnown().isPresent) 1 else 0) + + (metric.asKnown().getOrNull()?.validity() ?: 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + /** The customer the alert applies to. */ class Customer private constructor( @@ -692,6 +718,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -829,6 +874,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1098,6 +1159,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planVersion.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1235,6 +1317,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1380,6 +1478,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1501,6 +1615,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt index ab06c22b..daa6485f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt @@ -538,11 +538,31 @@ private constructor( } currency() - type() + type().validate() thresholds().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -652,6 +672,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -793,6 +840,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt index caa76db5..52fa366f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt @@ -544,11 +544,31 @@ private constructor( } currency() - type() + type().validate() thresholds().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -658,6 +678,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -799,6 +846,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt index 5aa2c875..fd1f910d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt @@ -542,11 +542,31 @@ private constructor( } thresholds().forEach { it.validate() } - type() + type().validate() metricId() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (metricId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -693,6 +713,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -796,6 +832,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt index e9b4474b..a49dabee 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.AlertService import java.util.Collections import java.util.Objects @@ -136,6 +137,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt index 4d3af4d1..19fde1bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.AlertServiceAsync import java.util.Collections import java.util.Objects @@ -138,6 +139,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt index 089cef3d..92c864c9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt @@ -19,6 +19,7 @@ import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull /** This endpoint updates the thresholds of an alert. */ class AlertUpdateParams @@ -402,6 +403,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -548,6 +567,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt index d7fc6768..9ea82316 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt @@ -274,11 +274,31 @@ private constructor( amountDiscount() appliesToPriceIds() - discountType() + discountType().validate() reason() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -360,6 +380,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt index 8585a17c..face5dc8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt @@ -320,10 +320,32 @@ private constructor( item().validate() metadata().validate() name() - status() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + /** * 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 @@ -395,6 +417,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -502,6 +542,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt index 9266aa90..1852fa6b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt @@ -96,6 +96,32 @@ private constructor(private val value: JsonField) : Enum { fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): BillingCycleRelativeDate = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt index a2c4dac0..ce4b90e6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt @@ -452,6 +452,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (archivedAt.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (durationInMonths.asKnown().isPresent) 1 else 0) + + (if (maxRedemptions.asKnown().isPresent) 1 else 0) + + (if (redemptionCode.asKnown().isPresent) 1 else 0) + + (if (timesRedeemed.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Discount.Deserializer::class) @JsonSerialize(using = Discount.Serializer::class) class Discount @@ -475,13 +498,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { percentage != null -> visitor.visitPercentage(percentage) amount != null -> visitor.visitAmount(amount) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -504,6 +526,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentage(percentage: PercentageDiscount) = + percentage.validity() + + override fun visitAmount(amount: AmountDiscount) = amount.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -563,16 +612,14 @@ private constructor( when (discountType) { "percentage" -> { - return Discount( - percentage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(percentage = it, _json = json) + } ?: Discount(_json = json) } "amount" -> { - return Discount( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(amount = it, _json = json) + } ?: Discount(_json = json) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt index 19d1b3b2..83e01d4c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt @@ -737,6 +737,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (redemptionCode.asKnown().isPresent) 1 else 0) + + (if (durationInMonths.asKnown().isPresent) 1 else 0) + + (if (maxRedemptions.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -782,13 +803,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newCouponPercentage != null -> visitor.visitNewCouponPercentage(newCouponPercentage) newCouponAmount != null -> visitor.visitNewCouponAmount(newCouponAmount) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -813,6 +833,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewCouponPercentage( + newCouponPercentage: NewCouponPercentageDiscount + ) = newCouponPercentage.validity() + + override fun visitNewCouponAmount(newCouponAmount: NewCouponAmountDiscount) = + newCouponAmount.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -875,18 +924,14 @@ private constructor( when (discountType) { "percentage" -> { - return Discount( - newCouponPercentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Discount(newCouponPercentage = it, _json = json) } + ?: Discount(_json = json) } "amount" -> { - return Discount( - newCouponAmount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Discount(newCouponAmount = it, _json = json) } + ?: Discount(_json = json) } } @@ -1083,11 +1128,30 @@ private constructor( return@apply } - discountType() + discountType().validate() percentageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1175,6 +1239,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1378,10 +1469,29 @@ private constructor( } amountDiscount() - discountType() + discountType().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1469,6 +1579,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt index 812a9001..9939054a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.CouponService import java.util.Collections import java.util.Objects @@ -132,6 +133,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt index 49150cde..3b1e71fb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.CouponServiceAsync import java.util.Collections import java.util.Objects @@ -134,6 +135,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt index 22529703..21f1e662 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.coupons.SubscriptionService import java.util.Collections import java.util.Objects @@ -134,6 +135,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt index 0199a125..c9bd5656 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import java.util.Collections import java.util.Objects @@ -136,6 +137,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt index 73704c29..c9228a33 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt @@ -772,15 +772,47 @@ private constructor( maximumAmountAdjustment().ifPresent { it.validate() } memo() minimumAmountRefunded() - reason() + reason().ifPresent { it.validate() } subtotal() total() - type() + type().validate() voidedAt() discounts().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (creditNoteNumber.asKnown().isPresent) 1 else 0) + + (if (creditNotePdf.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceId.asKnown().isPresent) 1 else 0) + + (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (maximumAmountAdjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (minimumAmountRefunded.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Customer private constructor( private val id: JsonField, @@ -950,6 +982,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1396,6 +1447,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (taxAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class TaxAmount private constructor( private val amount: JsonField, @@ -1622,6 +1698,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (taxRateDescription.asKnown().isPresent) 1 else 0) + + (if (taxRatePercentage.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2024,13 +2120,37 @@ private constructor( id() amountApplied() appliesToPriceIds() - discountType() + discountType().validate() percentageDiscount() amountDiscount() reason() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amountApplied.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2124,6 +2244,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2469,13 +2616,35 @@ private constructor( } amountApplied() - discountType() + discountType().validate() percentageDiscount() appliesToPrices().ifPresent { it.forEach { it.validate() } } reason() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountApplied.asKnown().isPresent) 1 else 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPrices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2559,6 +2728,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2730,6 +2926,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2862,6 +3076,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Reason = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2959,6 +3200,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3267,13 +3535,35 @@ private constructor( } amountApplied() - discountType() + discountType().validate() percentageDiscount() appliesToPrices().ifPresent { it.forEach { it.validate() } } reason() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountApplied.asKnown().isPresent) 1 else 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPrices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3357,6 +3647,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3528,6 +3845,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt index a44f7e88..a31d4a31 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt @@ -505,10 +505,30 @@ private constructor( lineItems().forEach { it.validate() } memo() - reason() + reason().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -694,6 +714,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (invoiceLineItemId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -809,6 +848,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Reason = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt index e61aa839..0b80d72f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.CreditNoteService import java.util.Collections import java.util.Objects @@ -133,6 +134,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt index 0b6c9f7f..e9db3e7b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.CreditNoteServiceAsync import java.util.Collections import java.util.Objects @@ -135,6 +136,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt index 2f05f017..2e73bf1a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -1275,7 +1275,7 @@ private constructor( hierarchy().validate() metadata().validate() name() - paymentProvider() + paymentProvider().ifPresent { it.validate() } paymentProviderId() portalUrl() shippingAddress().ifPresent { it.validate() } @@ -1286,6 +1286,44 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (additionalEmails.asKnown().getOrNull()?.size ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (balance.asKnown().isPresent) 1 else 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (emailDelivery.asKnown().isPresent) 1 else 0) + + (if (exemptFromAutomatedTax.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (hierarchy.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (if (portalUrl.asKnown().isPresent) 1 else 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (taxId.asKnown().getOrNull()?.validity() ?: 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (accountingSyncConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (reportingConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillingAddress private constructor( private val city: JsonField, @@ -1590,6 +1628,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1781,6 +1842,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (children.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (parent.asKnown().getOrNull()?.validity() ?: 0) + class Child private constructor( private val id: JsonField, @@ -1954,6 +2034,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2145,6 +2244,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2252,6 +2370,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2379,6 +2515,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2696,6 +2859,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2999,12 +3185,32 @@ private constructor( return@apply } - country() - type() + country().validate() + type().validate() value() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (country.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + class Country @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3549,6 +3755,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Country = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4061,6 +4294,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4274,6 +4534,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accountingProviders.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (excluded.asKnown().isPresent) 1 else 0) + class AccountingProvider private constructor( private val externalProviderId: JsonField, @@ -4451,10 +4730,29 @@ private constructor( } externalProviderId() - providerType() + providerType().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalProviderId.asKnown().isPresent) 1 else 0) + + (providerType.asKnown().getOrNull()?.validity() ?: 0) + class ProviderType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4548,6 +4846,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ProviderType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4718,6 +5043,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (exempt.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt index 0e2bc28e..601a114d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt @@ -499,11 +499,31 @@ private constructor( } amount() - type() + type().validate() description() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -606,6 +626,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt index 8560244a..2398d2ad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt @@ -486,7 +486,7 @@ private constructor( } id() - action() + action().validate() amount() createdAt() creditNote().ifPresent { it.validate() } @@ -494,10 +494,36 @@ private constructor( endingBalance() invoice().ifPresent { it.validate() } startingBalance() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNote.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Action @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -624,6 +650,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -758,6 +811,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -896,6 +965,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -997,6 +1082,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt index f867d2cd..ce40b241 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.customers.BalanceTransactionService import java.util.Collections import java.util.Objects @@ -157,6 +158,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt index cbb1c9f9..41173313 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.customers.BalanceTransactionServiceAsync import java.util.Collections import java.util.Objects @@ -159,6 +160,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt index 864290df..693a4e46 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt @@ -486,7 +486,7 @@ private constructor( } id() - action() + action().validate() amount() createdAt() creditNote().ifPresent { it.validate() } @@ -494,10 +494,36 @@ private constructor( endingBalance() invoice().ifPresent { it.validate() } startingBalance() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNote.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Action @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -624,6 +650,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -758,6 +811,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -896,6 +965,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -997,6 +1082,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt index a846e45d..fd63e2d1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt @@ -467,6 +467,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ViewMode = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt index edf2ea2a..b4c35fe8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt @@ -158,6 +158,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Data private constructor( private val perPriceCosts: JsonField>, @@ -451,6 +468,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (perPriceCosts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + class PerPriceCost private constructor( private val price: JsonField, @@ -893,6 +932,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt index 5e187a6e..75f29da0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt @@ -462,6 +462,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ViewMode = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt index 4edde920..66be2c2b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt @@ -154,6 +154,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Data private constructor( private val perPriceCosts: JsonField>, @@ -447,6 +464,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (perPriceCosts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + class PerPriceCost private constructor( private val price: JsonField, @@ -889,6 +928,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index 794d1fb7..9271ddd6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -2328,7 +2328,7 @@ private constructor( externalCustomerId() hierarchy().ifPresent { it.validate() } metadata().ifPresent { it.validate() } - paymentProvider() + paymentProvider().ifPresent { it.validate() } paymentProviderId() reportingConfiguration().ifPresent { it.validate() } shippingAddress().ifPresent { it.validate() } @@ -2338,6 +2338,41 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (email.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (accountingSyncConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (additionalEmails.asKnown().getOrNull()?.size ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (emailDelivery.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (hierarchy.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (reportingConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (taxConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (taxId.asKnown().getOrNull()?.validity() ?: 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2539,6 +2574,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accountingProviders.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (excluded.asKnown().isPresent) 1 else 0) + class AccountingProvider private constructor( private val externalProviderId: JsonField, @@ -2713,6 +2767,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalProviderId.asKnown().isPresent) 1 else 0) + + (if (providerType.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3029,6 +3102,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3235,6 +3331,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (childCustomerIds.asKnown().getOrNull()?.size ?: 0) + + (if (parentCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3324,6 +3439,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3451,6 +3584,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3585,6 +3745,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (exempt.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3883,6 +4059,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3924,13 +4123,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newAvalara != null -> visitor.visitNewAvalara(newAvalara) newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -3953,6 +4151,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = + newAvalara.validity() + + override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) = + newTaxJar.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4016,17 +4242,14 @@ private constructor( when (taxProvider) { "avalara" -> { - return TaxConfiguration( - newAvalara = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { TaxConfiguration(newAvalara = it, _json = json) } + ?: TaxConfiguration(_json = json) } "taxjar" -> { - return TaxConfiguration( - newTaxJar = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(newTaxJar = it, _json = json) + } ?: TaxConfiguration(_json = json) } } @@ -4263,11 +4486,31 @@ private constructor( } taxExempt() - taxProvider() + taxProvider().validate() taxExemptionCode() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxExemptionCode.asKnown().isPresent) 1 else 0) + class TaxProvider @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4354,6 +4597,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaxProvider = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4553,10 +4823,29 @@ private constructor( } taxExempt() - taxProvider() + taxProvider().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + class TaxProvider @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4643,6 +4932,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaxProvider = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4960,12 +5276,32 @@ private constructor( return@apply } - country() - type() + country().validate() + type().validate() value() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (country.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + class Country @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5510,6 +5846,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Country = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6022,6 +6385,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 16b0054d..cb0a76ac 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -527,8 +527,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { addIncrementCreditLedgerEntryRequestParams != null -> visitor.visitAddIncrementCreditLedgerEntryRequestParams( addIncrementCreditLedgerEntryRequestParams @@ -551,7 +551,6 @@ private constructor( ) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -600,6 +599,52 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAddIncrementCreditLedgerEntryRequestParams( + addIncrementCreditLedgerEntryRequestParams: + AddIncrementCreditLedgerEntryRequestParams + ) = addIncrementCreditLedgerEntryRequestParams.validity() + + override fun visitAddDecrementCreditLedgerEntryRequestParams( + addDecrementCreditLedgerEntryRequestParams: + AddDecrementCreditLedgerEntryRequestParams + ) = addDecrementCreditLedgerEntryRequestParams.validity() + + override fun visitAddExpirationChangeCreditLedgerEntryRequestParams( + addExpirationChangeCreditLedgerEntryRequestParams: + AddExpirationChangeCreditLedgerEntryRequestParams + ) = addExpirationChangeCreditLedgerEntryRequestParams.validity() + + override fun visitAddVoidCreditLedgerEntryRequestParams( + addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams + ) = addVoidCreditLedgerEntryRequestParams.validity() + + override fun visitAddAmendmentCreditLedgerEntryRequestParams( + addAmendmentCreditLedgerEntryRequestParams: + AddAmendmentCreditLedgerEntryRequestParams + ) = addAmendmentCreditLedgerEntryRequestParams.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -724,56 +769,51 @@ private constructor( when (entryType) { "increment" -> { - return Body( - addIncrementCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(addIncrementCreditLedgerEntryRequestParams = it, _json = json) + } ?: Body(_json = json) } "decrement" -> { - return Body( - addDecrementCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(addDecrementCreditLedgerEntryRequestParams = it, _json = json) + } ?: Body(_json = json) } "expiration_change" -> { - return Body( - addExpirationChangeCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef< - AddExpirationChangeCreditLedgerEntryRequestParams - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body( + addExpirationChangeCreditLedgerEntryRequestParams = it, + _json = json, + ) + } ?: Body(_json = json) } "void" -> { - return Body( - addVoidCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(addVoidCreditLedgerEntryRequestParams = it, _json = json) } + ?: Body(_json = json) } "amendment" -> { - return Body( - addAmendmentCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(addAmendmentCreditLedgerEntryRequestParams = it, _json = json) + } ?: Body(_json = json) } } @@ -1333,7 +1373,7 @@ private constructor( } amount() - entryType() + entryType().validate() currency() description() effectiveDate() @@ -1344,6 +1384,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (invoiceSettings.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1429,6 +1495,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1722,6 +1815,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1814,6 +1928,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2165,13 +2299,35 @@ private constructor( } amount() - entryType() + entryType().validate() currency() description() metadata().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2257,6 +2413,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2344,6 +2527,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2851,7 +3054,7 @@ private constructor( return@apply } - entryType() + entryType().validate() expiryDate() targetExpiryDate() amount() @@ -2862,6 +3065,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (targetExpiryDate.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2947,6 +3175,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3034,6 +3289,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3475,14 +3750,38 @@ private constructor( amount() blockId() - entryType() + entryType().validate() currency() description() metadata().ifPresent { it.validate() } - voidReason() + voidReason().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (voidReason.asKnown().getOrNull()?.validity() ?: 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3568,6 +3867,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3655,6 +3981,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3759,6 +4105,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): VoidReason = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4144,13 +4517,36 @@ private constructor( amount() blockId() - entryType() + entryType().validate() currency() description() metadata().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4236,6 +4632,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4323,6 +4746,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt index d724db6f..773c7bae 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt @@ -104,8 +104,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) expirationChangeLedgerEntry != null -> @@ -118,7 +118,6 @@ private constructor( amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -167,6 +166,51 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = + incrementLedgerEntry.validity() + + override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = + decrementLedgerEntry.validity() + + override fun visitExpirationChangeLedgerEntry( + expirationChangeLedgerEntry: ExpirationChangeLedgerEntry + ) = expirationChangeLedgerEntry.validity() + + override fun visitCreditBlockExpiryLedgerEntry( + creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry + ) = creditBlockExpiryLedgerEntry.validity() + + override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = + voidLedgerEntry.validity() + + override fun visitVoidInitiatedLedgerEntry( + voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry + ) = voidInitiatedLedgerEntry.validity() + + override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = + amendmentLedgerEntry.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -302,52 +346,62 @@ private constructor( when (entryType) { "increment" -> { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - incrementLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + incrementLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "decrement" -> { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - decrementLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + decrementLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "expiration_change" -> { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - expirationChangeLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + expirationChangeLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "credit_block_expiry" -> { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - creditBlockExpiryLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + creditBlockExpiryLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "void" -> { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidLedgerEntry = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + voidLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "void_initiated" -> { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidInitiatedLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + voidInitiatedLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "amendment" -> { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - amendmentLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + amendmentLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } } @@ -971,14 +1025,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -1197,6 +1281,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1388,6 +1492,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1495,6 +1618,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1591,6 +1741,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1678,6 +1855,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2397,8 +2592,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() @@ -2408,6 +2603,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (eventId.asKnown().isPresent) 1 else 0) + + (if (invoiceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -2626,6 +2854,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2817,6 +3065,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2924,6 +3191,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3020,6 +3314,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3107,6 +3428,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3775,8 +4114,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -3784,6 +4123,37 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -4002,6 +4372,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4193,6 +4583,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4300,6 +4709,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4396,6 +4832,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4483,6 +4946,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5103,14 +5584,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -5329,6 +5840,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5520,6 +6051,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5627,6 +6177,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5723,6 +6300,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5810,6 +6414,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6504,8 +7126,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() @@ -6514,6 +7136,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (voidAmount.asKnown().isPresent) 1 else 0) + + (if (voidReason.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -6732,6 +7386,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6923,6 +7597,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7030,6 +7723,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7126,6 +7846,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7213,6 +7960,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7948,8 +8713,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -7959,6 +8724,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (voidAmount.asKnown().isPresent) 1 else 0) + + (if (voidReason.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -8177,6 +8975,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8368,6 +9186,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8475,6 +9312,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8571,6 +9435,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8658,6 +9549,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9276,14 +10185,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -9502,6 +10441,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9693,6 +10652,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9800,6 +10778,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9896,6 +10901,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9983,6 +11015,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 9f9f60b6..a07e3234 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -522,8 +522,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { addIncrementCreditLedgerEntryRequestParams != null -> visitor.visitAddIncrementCreditLedgerEntryRequestParams( addIncrementCreditLedgerEntryRequestParams @@ -546,7 +546,6 @@ private constructor( ) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -595,6 +594,52 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAddIncrementCreditLedgerEntryRequestParams( + addIncrementCreditLedgerEntryRequestParams: + AddIncrementCreditLedgerEntryRequestParams + ) = addIncrementCreditLedgerEntryRequestParams.validity() + + override fun visitAddDecrementCreditLedgerEntryRequestParams( + addDecrementCreditLedgerEntryRequestParams: + AddDecrementCreditLedgerEntryRequestParams + ) = addDecrementCreditLedgerEntryRequestParams.validity() + + override fun visitAddExpirationChangeCreditLedgerEntryRequestParams( + addExpirationChangeCreditLedgerEntryRequestParams: + AddExpirationChangeCreditLedgerEntryRequestParams + ) = addExpirationChangeCreditLedgerEntryRequestParams.validity() + + override fun visitAddVoidCreditLedgerEntryRequestParams( + addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams + ) = addVoidCreditLedgerEntryRequestParams.validity() + + override fun visitAddAmendmentCreditLedgerEntryRequestParams( + addAmendmentCreditLedgerEntryRequestParams: + AddAmendmentCreditLedgerEntryRequestParams + ) = addAmendmentCreditLedgerEntryRequestParams.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -719,56 +764,51 @@ private constructor( when (entryType) { "increment" -> { - return Body( - addIncrementCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(addIncrementCreditLedgerEntryRequestParams = it, _json = json) + } ?: Body(_json = json) } "decrement" -> { - return Body( - addDecrementCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(addDecrementCreditLedgerEntryRequestParams = it, _json = json) + } ?: Body(_json = json) } "expiration_change" -> { - return Body( - addExpirationChangeCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef< - AddExpirationChangeCreditLedgerEntryRequestParams - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body( + addExpirationChangeCreditLedgerEntryRequestParams = it, + _json = json, + ) + } ?: Body(_json = json) } "void" -> { - return Body( - addVoidCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(addVoidCreditLedgerEntryRequestParams = it, _json = json) } + ?: Body(_json = json) } "amendment" -> { - return Body( - addAmendmentCreditLedgerEntryRequestParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(addAmendmentCreditLedgerEntryRequestParams = it, _json = json) + } ?: Body(_json = json) } } @@ -1328,7 +1368,7 @@ private constructor( } amount() - entryType() + entryType().validate() currency() description() effectiveDate() @@ -1339,6 +1379,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (invoiceSettings.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1424,6 +1490,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1717,6 +1810,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1809,6 +1923,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2160,13 +2294,35 @@ private constructor( } amount() - entryType() + entryType().validate() currency() description() metadata().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2252,6 +2408,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2339,6 +2522,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2846,7 +3049,7 @@ private constructor( return@apply } - entryType() + entryType().validate() expiryDate() targetExpiryDate() amount() @@ -2857,6 +3060,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (targetExpiryDate.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2942,6 +3170,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3029,6 +3284,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3470,14 +3745,38 @@ private constructor( amount() blockId() - entryType() + entryType().validate() currency() description() metadata().ifPresent { it.validate() } - voidReason() + voidReason().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (voidReason.asKnown().getOrNull()?.validity() ?: 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3563,6 +3862,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3650,6 +3976,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3754,6 +4100,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): VoidReason = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4139,13 +4512,36 @@ private constructor( amount() blockId() - entryType() + entryType().validate() currency() description() metadata().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class EntryType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4231,6 +4627,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4318,6 +4741,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt index cb660d53..aafcb4ed 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt @@ -104,8 +104,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) expirationChangeLedgerEntry != null -> @@ -118,7 +118,6 @@ private constructor( amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -167,6 +166,51 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = + incrementLedgerEntry.validity() + + override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = + decrementLedgerEntry.validity() + + override fun visitExpirationChangeLedgerEntry( + expirationChangeLedgerEntry: ExpirationChangeLedgerEntry + ) = expirationChangeLedgerEntry.validity() + + override fun visitCreditBlockExpiryLedgerEntry( + creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry + ) = creditBlockExpiryLedgerEntry.validity() + + override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = + voidLedgerEntry.validity() + + override fun visitVoidInitiatedLedgerEntry( + voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry + ) = voidInitiatedLedgerEntry.validity() + + override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = + amendmentLedgerEntry.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -291,52 +335,59 @@ private constructor( when (entryType) { "increment" -> { - return CustomerCreditLedgerCreateEntryResponse( - incrementLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse( + incrementLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "decrement" -> { - return CustomerCreditLedgerCreateEntryResponse( - decrementLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse( + decrementLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "expiration_change" -> { - return CustomerCreditLedgerCreateEntryResponse( - expirationChangeLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + CustomerCreditLedgerCreateEntryResponse( + expirationChangeLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "credit_block_expiry" -> { - return CustomerCreditLedgerCreateEntryResponse( - creditBlockExpiryLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + CustomerCreditLedgerCreateEntryResponse( + creditBlockExpiryLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "void" -> { - return CustomerCreditLedgerCreateEntryResponse( - voidLedgerEntry = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse(voidLedgerEntry = it, _json = json) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "void_initiated" -> { - return CustomerCreditLedgerCreateEntryResponse( - voidInitiatedLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse( + voidInitiatedLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "amendment" -> { - return CustomerCreditLedgerCreateEntryResponse( - amendmentLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse( + amendmentLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } } @@ -958,14 +1009,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -1184,6 +1265,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1375,6 +1476,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1482,6 +1602,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1578,6 +1725,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1665,6 +1839,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2384,8 +2576,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() @@ -2395,6 +2587,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (eventId.asKnown().isPresent) 1 else 0) + + (if (invoiceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -2613,6 +2838,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2804,6 +3049,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2911,6 +3175,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3007,6 +3298,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3094,6 +3412,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3762,8 +4098,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -3771,6 +4107,37 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -3989,6 +4356,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4180,6 +4567,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4287,6 +4693,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4383,6 +4816,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4470,6 +4930,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5090,14 +5568,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -5316,6 +5824,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5507,6 +6035,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5614,6 +6161,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5710,6 +6284,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5797,6 +6398,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6491,8 +7110,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() @@ -6501,6 +7120,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (voidAmount.asKnown().isPresent) 1 else 0) + + (if (voidReason.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -6719,6 +7370,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6910,6 +7581,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7017,6 +7707,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7113,6 +7830,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7200,6 +7944,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7935,8 +8697,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -7946,6 +8708,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (voidAmount.asKnown().isPresent) 1 else 0) + + (if (voidReason.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -8164,6 +8959,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8355,6 +9170,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8462,6 +9296,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8558,6 +9419,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8645,6 +9533,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9263,14 +10169,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -9489,6 +10425,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9680,6 +10636,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9787,6 +10762,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9883,6 +10885,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9970,6 +10999,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt index 0335a1e1..d26c9ab7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.customers.credits.LedgerService import java.util.Collections import java.util.Objects @@ -208,6 +209,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt index 07bfabe6..853422bf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import java.util.Collections import java.util.Objects @@ -210,6 +211,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt index 739b45d8..2271ced0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt @@ -516,6 +516,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -645,6 +672,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt index b30e0a89..d9d2e5ec 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt @@ -104,8 +104,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) expirationChangeLedgerEntry != null -> @@ -118,7 +118,6 @@ private constructor( amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -167,6 +166,51 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = + incrementLedgerEntry.validity() + + override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = + decrementLedgerEntry.validity() + + override fun visitExpirationChangeLedgerEntry( + expirationChangeLedgerEntry: ExpirationChangeLedgerEntry + ) = expirationChangeLedgerEntry.validity() + + override fun visitCreditBlockExpiryLedgerEntry( + creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry + ) = creditBlockExpiryLedgerEntry.validity() + + override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = + voidLedgerEntry.validity() + + override fun visitVoidInitiatedLedgerEntry( + voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry + ) = voidInitiatedLedgerEntry.validity() + + override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = + amendmentLedgerEntry.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -300,52 +344,62 @@ private constructor( when (entryType) { "increment" -> { - return CustomerCreditLedgerListByExternalIdResponse( - incrementLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse( + incrementLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } "decrement" -> { - return CustomerCreditLedgerListByExternalIdResponse( - decrementLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse( + decrementLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } "expiration_change" -> { - return CustomerCreditLedgerListByExternalIdResponse( - expirationChangeLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + CustomerCreditLedgerListByExternalIdResponse( + expirationChangeLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } "credit_block_expiry" -> { - return CustomerCreditLedgerListByExternalIdResponse( - creditBlockExpiryLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + CustomerCreditLedgerListByExternalIdResponse( + creditBlockExpiryLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } "void" -> { - return CustomerCreditLedgerListByExternalIdResponse( - voidLedgerEntry = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse( + voidLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } "void_initiated" -> { - return CustomerCreditLedgerListByExternalIdResponse( - voidInitiatedLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse( + voidInitiatedLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } "amendment" -> { - return CustomerCreditLedgerListByExternalIdResponse( - amendmentLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse( + amendmentLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } } @@ -969,14 +1023,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -1195,6 +1279,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1386,6 +1490,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1493,6 +1616,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1589,6 +1739,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1676,6 +1853,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2395,8 +2590,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() @@ -2406,6 +2601,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (eventId.asKnown().isPresent) 1 else 0) + + (if (invoiceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -2624,6 +2852,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2815,6 +3063,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2922,6 +3189,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3018,6 +3312,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3105,6 +3426,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3773,8 +4112,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -3782,6 +4121,37 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -4000,6 +4370,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4191,6 +4581,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4298,6 +4707,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4394,6 +4830,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4481,6 +4944,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5101,14 +5582,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -5327,6 +5838,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5518,6 +6049,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5625,6 +6175,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5721,6 +6298,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5808,6 +6412,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6502,8 +7124,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() @@ -6512,6 +7134,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (voidAmount.asKnown().isPresent) 1 else 0) + + (if (voidReason.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -6730,6 +7384,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6921,6 +7595,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7028,6 +7721,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7124,6 +7844,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7211,6 +7958,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7946,8 +8711,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -7957,6 +8722,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (voidAmount.asKnown().isPresent) 1 else 0) + + (if (voidReason.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -8175,6 +8973,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8366,6 +9184,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8473,6 +9310,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8569,6 +9433,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8656,6 +9547,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9274,14 +10183,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -9500,6 +10439,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9691,6 +10650,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9798,6 +10776,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9894,6 +10899,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9981,6 +11013,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt index 650287b1..ecc6ed2a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.customers.credits.LedgerService import java.util.Collections import java.util.Objects @@ -207,6 +208,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt index cff005eb..48e5c277 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import java.util.Collections import java.util.Objects @@ -209,6 +210,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt index 35c503f5..9d9efa69 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt @@ -510,6 +510,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -639,6 +666,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt index 81c15399..edb510d6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt @@ -104,8 +104,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) expirationChangeLedgerEntry != null -> @@ -118,7 +118,6 @@ private constructor( amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -167,6 +166,51 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = + incrementLedgerEntry.validity() + + override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = + decrementLedgerEntry.validity() + + override fun visitExpirationChangeLedgerEntry( + expirationChangeLedgerEntry: ExpirationChangeLedgerEntry + ) = expirationChangeLedgerEntry.validity() + + override fun visitCreditBlockExpiryLedgerEntry( + creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry + ) = creditBlockExpiryLedgerEntry.validity() + + override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = + voidLedgerEntry.validity() + + override fun visitVoidInitiatedLedgerEntry( + voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry + ) = voidInitiatedLedgerEntry.validity() + + override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = + amendmentLedgerEntry.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -286,52 +330,50 @@ private constructor( when (entryType) { "increment" -> { - return CustomerCreditLedgerListResponse( - incrementLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(incrementLedgerEntry = it, _json = json) + } ?: CustomerCreditLedgerListResponse(_json = json) } "decrement" -> { - return CustomerCreditLedgerListResponse( - decrementLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(decrementLedgerEntry = it, _json = json) + } ?: CustomerCreditLedgerListResponse(_json = json) } "expiration_change" -> { - return CustomerCreditLedgerListResponse( - expirationChangeLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + CustomerCreditLedgerListResponse( + expirationChangeLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListResponse(_json = json) } "credit_block_expiry" -> { - return CustomerCreditLedgerListResponse( - creditBlockExpiryLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + CustomerCreditLedgerListResponse( + creditBlockExpiryLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListResponse(_json = json) } "void" -> { - return CustomerCreditLedgerListResponse( - voidLedgerEntry = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(voidLedgerEntry = it, _json = json) + } ?: CustomerCreditLedgerListResponse(_json = json) } "void_initiated" -> { - return CustomerCreditLedgerListResponse( - voidInitiatedLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse( + voidInitiatedLedgerEntry = it, + _json = json, + ) + } ?: CustomerCreditLedgerListResponse(_json = json) } "amendment" -> { - return CustomerCreditLedgerListResponse( - amendmentLedgerEntry = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(amendmentLedgerEntry = it, _json = json) + } ?: CustomerCreditLedgerListResponse(_json = json) } } @@ -950,14 +992,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -1176,6 +1248,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1367,6 +1459,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1474,6 +1585,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1570,6 +1708,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1657,6 +1822,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2376,8 +2559,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() @@ -2387,6 +2570,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (eventId.asKnown().isPresent) 1 else 0) + + (if (invoiceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -2605,6 +2821,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2796,6 +3032,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2903,6 +3158,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2999,6 +3281,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3086,6 +3395,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3754,8 +4081,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -3763,6 +4090,37 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -3981,6 +4339,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4172,6 +4550,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4279,6 +4676,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4375,6 +4799,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4462,6 +4913,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5082,14 +5551,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -5308,6 +5807,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5499,6 +6018,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5606,6 +6144,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5702,6 +6267,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5789,6 +6381,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6483,8 +7093,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() @@ -6493,6 +7103,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (voidAmount.asKnown().isPresent) 1 else 0) + + (if (voidReason.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -6711,6 +7353,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6902,6 +7564,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7009,6 +7690,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7105,6 +7813,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7192,6 +7927,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7927,8 +8680,8 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -7938,6 +8691,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (voidAmount.asKnown().isPresent) 1 else 0) + + (if (voidReason.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -8156,6 +8942,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8347,6 +9153,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8454,6 +9279,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8550,6 +9402,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8637,6 +9516,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9255,14 +10152,44 @@ private constructor( customer().validate() description() endingBalance() - entryStatus() - entryType() + entryStatus().validate() + entryType().validate() ledgerSequenceNumber() metadata().validate() startingBalance() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditBlock.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (entryType.asKnown().getOrNull()?.validity() ?: 0) + + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + class CreditBlock private constructor( private val id: JsonField, @@ -9481,6 +10408,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9672,6 +10619,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9779,6 +10745,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryStatus = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9875,6 +10868,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): EntryType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9962,6 +10982,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt index 28b2175d..a0a313bd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.customers.CreditService import java.util.Collections import java.util.Objects @@ -140,6 +141,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt index f97f7b30..183db5fb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.Collections import java.util.Objects @@ -142,6 +143,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index 20e72ffd..a3aad357 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -397,10 +397,33 @@ private constructor( expiryDate() maximumInitialBalance() perUnitCostBasis() - status() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (balance.asKnown().isPresent) 1 else 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -485,6 +508,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt index 34c10cb8..1a3a4cd1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.customers.CreditService import java.util.Collections import java.util.Objects @@ -139,6 +140,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt index 51d1d0d1..28fa0aa2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.Collections import java.util.Objects @@ -141,6 +142,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index 1b121e8a..1e4451c4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -393,10 +393,33 @@ private constructor( expiryDate() maximumInitialBalance() perUnitCostBasis() - status() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (balance.asKnown().isPresent) 1 else 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -481,6 +504,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt index 1c5a9c37..e0d32c2c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt @@ -958,10 +958,35 @@ private constructor( threshold() activeFrom() expiresAfter() - expiresAfterUnit() + expiresAfterUnit().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (invoiceSettings.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (activeFrom.asKnown().isPresent) 1 else 0) + + (if (expiresAfter.asKnown().isPresent) 1 else 0) + + (expiresAfterUnit.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1238,6 +1263,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1345,6 +1391,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExpiresAfterUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt index 0c7f139d..f21258d3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt @@ -443,10 +443,34 @@ private constructor( perUnitCostBasis() threshold() expiresAfter() - expiresAfterUnit() + expiresAfterUnit().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (invoiceSettings.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (expiresAfter.asKnown().isPresent) 1 else 0) + + (expiresAfterUnit.asKnown().getOrNull()?.validity() ?: 0) + /** Settings for invoices generated by triggered top-ups. */ class InvoiceSettings private constructor( @@ -705,6 +729,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -812,6 +857,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExpiresAfterUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt index 59a9d5db..b27cc368 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt @@ -954,10 +954,35 @@ private constructor( threshold() activeFrom() expiresAfter() - expiresAfterUnit() + expiresAfterUnit().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (invoiceSettings.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (activeFrom.asKnown().isPresent) 1 else 0) + + (if (expiresAfter.asKnown().isPresent) 1 else 0) + + (expiresAfterUnit.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1234,6 +1259,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1341,6 +1387,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExpiresAfterUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt index cff36b4b..04724cef 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt @@ -441,10 +441,34 @@ private constructor( perUnitCostBasis() threshold() expiresAfter() - expiresAfterUnit() + expiresAfterUnit().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (invoiceSettings.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (expiresAfter.asKnown().isPresent) 1 else 0) + + (expiresAfterUnit.asKnown().getOrNull()?.validity() ?: 0) + /** Settings for invoices generated by triggered top-ups. */ class InvoiceSettings private constructor( @@ -703,6 +727,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -810,6 +855,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExpiresAfterUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt index f4cee4cb..385a7a54 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.Collections import java.util.Objects @@ -132,6 +133,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt index 0d676ee5..975efb67 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.Collections import java.util.Objects @@ -134,6 +135,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt index d5e2adee..7d6c8232 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt @@ -442,10 +442,34 @@ private constructor( perUnitCostBasis() threshold() expiresAfter() - expiresAfterUnit() + expiresAfterUnit().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (invoiceSettings.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (expiresAfter.asKnown().isPresent) 1 else 0) + + (expiresAfterUnit.asKnown().getOrNull()?.validity() ?: 0) + /** Settings for invoices generated by triggered top-ups. */ class InvoiceSettings private constructor( @@ -704,6 +728,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -811,6 +856,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExpiresAfterUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt index db733984..2865107b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.Collections import java.util.Objects @@ -131,6 +132,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt index 53804a58..31b3a249 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.Collections import java.util.Objects @@ -133,6 +134,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt index 8f1e18dc..331562cb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt @@ -441,10 +441,34 @@ private constructor( perUnitCostBasis() threshold() expiresAfter() - expiresAfterUnit() + expiresAfterUnit().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (invoiceSettings.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (expiresAfter.asKnown().isPresent) 1 else 0) + + (expiresAfterUnit.asKnown().getOrNull()?.validity() ?: 0) + /** Settings for invoices generated by triggered top-ups. */ class InvoiceSettings private constructor( @@ -703,6 +727,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -810,6 +855,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExpiresAfterUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt index 3b918190..775b1e75 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.CustomerService import java.util.Collections import java.util.Objects @@ -132,6 +133,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt index cd9e93db..77559c10 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.CustomerServiceAsync import java.util.Collections import java.util.Objects @@ -137,6 +138,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 914eead0..468fc632 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -2257,7 +2257,7 @@ private constructor( hierarchy().ifPresent { it.validate() } metadata().ifPresent { it.validate() } name() - paymentProvider() + paymentProvider().ifPresent { it.validate() } paymentProviderId() reportingConfiguration().ifPresent { it.validate() } shippingAddress().ifPresent { it.validate() } @@ -2266,6 +2266,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accountingSyncConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (additionalEmails.asKnown().getOrNull()?.size ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (emailDelivery.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (hierarchy.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (reportingConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (taxConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (taxId.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2467,6 +2501,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accountingProviders.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (excluded.asKnown().isPresent) 1 else 0) + class AccountingProvider private constructor( private val externalProviderId: JsonField, @@ -2641,6 +2694,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalProviderId.asKnown().isPresent) 1 else 0) + + (if (providerType.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2957,6 +3029,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3163,6 +3258,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (childCustomerIds.asKnown().getOrNull()?.size ?: 0) + + (if (parentCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3252,6 +3366,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3382,6 +3514,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3516,6 +3675,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (exempt.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3814,6 +3989,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3855,13 +4053,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newAvalara != null -> visitor.visitNewAvalara(newAvalara) newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -3884,6 +4081,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = + newAvalara.validity() + + override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) = + newTaxJar.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3947,17 +4172,14 @@ private constructor( when (taxProvider) { "avalara" -> { - return TaxConfiguration( - newAvalara = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { TaxConfiguration(newAvalara = it, _json = json) } + ?: TaxConfiguration(_json = json) } "taxjar" -> { - return TaxConfiguration( - newTaxJar = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(newTaxJar = it, _json = json) + } ?: TaxConfiguration(_json = json) } } @@ -4194,11 +4416,31 @@ private constructor( } taxExempt() - taxProvider() + taxProvider().validate() taxExemptionCode() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxExemptionCode.asKnown().isPresent) 1 else 0) + class TaxProvider @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4285,6 +4527,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaxProvider = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4484,10 +4753,29 @@ private constructor( } taxExempt() - taxProvider() + taxProvider().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + class TaxProvider @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4574,6 +4862,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaxProvider = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4891,12 +5206,32 @@ private constructor( return@apply } - country() - type() + country().validate() + type().validate() value() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (country.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + class Country @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5441,6 +5776,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Country = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5953,6 +6315,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 9f7b8181..7cefced6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -2253,7 +2253,7 @@ private constructor( hierarchy().ifPresent { it.validate() } metadata().ifPresent { it.validate() } name() - paymentProvider() + paymentProvider().ifPresent { it.validate() } paymentProviderId() reportingConfiguration().ifPresent { it.validate() } shippingAddress().ifPresent { it.validate() } @@ -2262,6 +2262,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accountingSyncConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (additionalEmails.asKnown().getOrNull()?.size ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (emailDelivery.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (hierarchy.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (reportingConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (taxConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (taxId.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2463,6 +2497,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accountingProviders.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (excluded.asKnown().isPresent) 1 else 0) + class AccountingProvider private constructor( private val externalProviderId: JsonField, @@ -2637,6 +2690,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalProviderId.asKnown().isPresent) 1 else 0) + + (if (providerType.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2953,6 +3025,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3159,6 +3254,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (childCustomerIds.asKnown().getOrNull()?.size ?: 0) + + (if (parentCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3248,6 +3362,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3378,6 +3510,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3512,6 +3671,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (exempt.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3810,6 +3985,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3851,13 +4049,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newAvalara != null -> visitor.visitNewAvalara(newAvalara) newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -3880,6 +4077,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = + newAvalara.validity() + + override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) = + newTaxJar.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3943,17 +4168,14 @@ private constructor( when (taxProvider) { "avalara" -> { - return TaxConfiguration( - newAvalara = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { TaxConfiguration(newAvalara = it, _json = json) } + ?: TaxConfiguration(_json = json) } "taxjar" -> { - return TaxConfiguration( - newTaxJar = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(newTaxJar = it, _json = json) + } ?: TaxConfiguration(_json = json) } } @@ -4190,11 +4412,31 @@ private constructor( } taxExempt() - taxProvider() + taxProvider().validate() taxExemptionCode() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxExemptionCode.asKnown().isPresent) 1 else 0) + class TaxProvider @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4281,6 +4523,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaxProvider = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4480,10 +4749,29 @@ private constructor( } taxExempt() - taxProvider() + taxProvider().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + class TaxProvider @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4570,6 +4858,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaxProvider = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4887,12 +5202,32 @@ private constructor( return@apply } - country() - type() + country().validate() + type().validate() value() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (country.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + class Country @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5437,6 +5772,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Country = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5949,6 +6311,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt index 7b13f317..76e731bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt @@ -380,6 +380,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.size ?: 0) + + (if (externalDimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + /** * 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 @@ -451,6 +473,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt index 60882cb7..770736f6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt @@ -698,6 +698,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.size ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (externalDimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -787,6 +809,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt index 9010b26a..a6cfcbfd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.DimensionalPriceGroupService import java.util.Collections import java.util.Objects @@ -129,6 +130,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt index c738ed60..fe06e9ba 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.DimensionalPriceGroupServiceAsync import java.util.Collections import java.util.Objects @@ -131,6 +132,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt index f4ba6a0b..e69db0a4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt @@ -16,6 +16,7 @@ import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull class DimensionalPriceGroups private constructor( @@ -195,6 +196,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt index 109c0639..cc00f9b5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt @@ -55,15 +55,14 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { percentage != null -> visitor.visitPercentage(percentage) trial != null -> visitor.visitTrial(trial) usage != null -> visitor.visitUsage(usage) amount != null -> visitor.visitAmount(amount) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -94,6 +93,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentage(percentage: PercentageDiscount) = percentage.validity() + + override fun visitTrial(trial: TrialDiscount) = trial.validity() + + override fun visitUsage(usage: UsageDiscount) = usage.validity() + + override fun visitAmount(amount: AmountDiscount) = amount.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -160,28 +188,24 @@ private constructor( when (discountType) { "percentage" -> { - return Discount( - percentage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(percentage = it, _json = json) + } ?: Discount(_json = json) } "trial" -> { - return Discount( - trial = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(trial = it, _json = json) + } ?: Discount(_json = json) } "usage" -> { - return Discount( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(usage = it, _json = json) + } ?: Discount(_json = json) } "amount" -> { - return Discount( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(amount = it, _json = json) + } ?: Discount(_json = json) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt index e4846fca..6e601e88 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt @@ -19,6 +19,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.allMaxBy import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow @@ -27,6 +28,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull class EvaluatePriceGroup private constructor( @@ -248,6 +250,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (groupingValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = GroupingValue.Deserializer::class) @JsonSerialize(using = GroupingValue.Serializer::class) class GroupingValue @@ -278,14 +299,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -306,6 +326,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -366,17 +414,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): GroupingValue { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return GroupingValue(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + GroupingValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + GroupingValue(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + GroupingValue(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> GroupingValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return GroupingValue(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return GroupingValue(bool = it, _json = json) - } - - return GroupingValue(_json = json) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt index 65a057e2..a3d1568a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt @@ -573,13 +573,40 @@ private constructor( eventsIngested() replaceExistingEvents() revertedAt() - status() + status().validate() timeframeEnd() timeframeStart() deprecationFilter() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (closeTime.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (eventsIngested.asKnown().isPresent) 1 else 0) + + (if (replaceExistingEvents.asKnown().isPresent) 1 else 0) + + (if (revertedAt.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (deprecationFilter.asKnown().isPresent) 1 else 0) + /** The status of the backfill. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -677,6 +704,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index 5097b8a1..0460247f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -939,6 +939,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (closeTime.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (deprecationFilter.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (if (replaceExistingEvents.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt index ee1edad7..2908ae40 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt @@ -573,13 +573,40 @@ private constructor( eventsIngested() replaceExistingEvents() revertedAt() - status() + status().validate() timeframeEnd() timeframeStart() deprecationFilter() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (closeTime.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (eventsIngested.asKnown().isPresent) 1 else 0) + + (if (replaceExistingEvents.asKnown().isPresent) 1 else 0) + + (if (revertedAt.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (deprecationFilter.asKnown().isPresent) 1 else 0) + /** The status of the backfill. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -677,6 +704,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt index 7a6200ec..51630d70 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt @@ -573,13 +573,40 @@ private constructor( eventsIngested() replaceExistingEvents() revertedAt() - status() + status().validate() timeframeEnd() timeframeStart() deprecationFilter() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (closeTime.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (eventsIngested.asKnown().isPresent) 1 else 0) + + (if (replaceExistingEvents.asKnown().isPresent) 1 else 0) + + (if (revertedAt.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (deprecationFilter.asKnown().isPresent) 1 else 0) + /** The status of the backfill. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -677,6 +704,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt index 7539f86c..6a8d92bd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.events.BackfillService import java.util.Collections import java.util.Objects @@ -138,6 +139,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt index 33983f33..a38f6421 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.events.BackfillServiceAsync import java.util.Collections import java.util.Objects @@ -140,6 +141,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt index 2967db47..66e717db 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt @@ -573,13 +573,40 @@ private constructor( eventsIngested() replaceExistingEvents() revertedAt() - status() + status().validate() timeframeEnd() timeframeStart() deprecationFilter() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (closeTime.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (eventsIngested.asKnown().isPresent) 1 else 0) + + (if (replaceExistingEvents.asKnown().isPresent) 1 else 0) + + (if (revertedAt.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (deprecationFilter.asKnown().isPresent) 1 else 0) + /** The status of the backfill. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -677,6 +704,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt index 86e5bef8..bb7b30eb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt @@ -573,13 +573,40 @@ private constructor( eventsIngested() replaceExistingEvents() revertedAt() - status() + status().validate() timeframeEnd() timeframeStart() deprecationFilter() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (closeTime.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (eventsIngested.asKnown().isPresent) 1 else 0) + + (if (replaceExistingEvents.asKnown().isPresent) 1 else 0) + + (if (revertedAt.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (deprecationFilter.asKnown().isPresent) 1 else 0) + /** The status of the backfill. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -677,6 +704,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt index 0bd29adf..26d75833 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt @@ -139,6 +139,21 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (deprecated.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt index ea3cd0c0..7801c30d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt @@ -610,6 +610,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -968,6 +986,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (eventName.asKnown().isPresent) 1 else 0) + + (if (idempotencyKey.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt index 3a46d327..ad163e5e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt @@ -207,6 +207,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (validationFailed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (debug.asKnown().getOrNull()?.validity() ?: 0) + class ValidationFailed private constructor( private val idempotencyKey: JsonField, @@ -396,6 +414,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (idempotencyKey.asKnown().isPresent) 1 else 0) + + (validationErrors.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -607,6 +644,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (duplicate.asKnown().getOrNull()?.size ?: 0) + + (ingested.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt index 9943b0a2..b1f99dcb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt @@ -586,6 +586,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (eventIds.asKnown().getOrNull()?.size ?: 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt index 0d5ff15c..64489f98 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt @@ -154,6 +154,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** * 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 @@ -536,6 +553,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (deprecated.asKnown().isPresent) 1 else 0) + + (if (eventName.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt index ce068e6b..0e690366 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt @@ -689,6 +689,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (eventName.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt index e376ea36..640c262d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt @@ -138,6 +138,21 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (amended.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt index 7b28ca52..dc6a3602 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt @@ -17,6 +17,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull class EventVolumes private constructor( @@ -152,6 +153,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** * An EventVolume contains the event volume ingested in an hourly window. The timestamp used for * the aggregation is the `timestamp` datetime field on events. @@ -360,6 +378,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index dfbe313d..90fa9fb8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -2151,7 +2151,7 @@ private constructor( invoiceDate() invoiceNumber() invoicePdf() - invoiceSource() + invoiceSource().validate() issueFailedAt() issuedAt() lineItems().forEach { it.validate() } @@ -2167,7 +2167,7 @@ private constructor( paymentStartedAt() scheduledIssueAt() shippingAddress().ifPresent { it.validate() } - status() + status().validate() subscription().ifPresent { it.validate() } subtotal() syncFailedAt() @@ -2177,6 +2177,63 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amountDue.asKnown().isPresent) 1 else 0) + + (autoCollection.asKnown().getOrNull()?.validity() ?: 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (customerBalanceTransactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (customerTaxId.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (dueDate.asKnown().isPresent) 1 else 0) + + (if (eligibleToIssueAt.asKnown().isPresent) 1 else 0) + + (if (hostedInvoiceUrl.asKnown().isPresent) 1 else 0) + + (if (invoiceDate.asKnown().isPresent) 1 else 0) + + (if (invoiceNumber.asKnown().isPresent) 1 else 0) + + (if (invoicePdf.asKnown().isPresent) 1 else 0) + + (invoiceSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (issueFailedAt.asKnown().isPresent) 1 else 0) + + (if (issuedAt.asKnown().isPresent) 1 else 0) + + (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (paidAt.asKnown().isPresent) 1 else 0) + + (paymentAttempts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (paymentFailedAt.asKnown().isPresent) 1 else 0) + + (if (paymentStartedAt.asKnown().isPresent) 1 else 0) + + (if (scheduledIssueAt.asKnown().isPresent) 1 else 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (syncFailedAt.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + (if (willAutoIssue.asKnown().isPresent) 1 else 0) + class AutoCollection private constructor( private val enabled: JsonField, @@ -2478,6 +2535,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (enabled.asKnown().isPresent) 1 else 0) + + (if (nextAttemptAt.asKnown().isPresent) 1 else 0) + + (if (numAttempts.asKnown().isPresent) 1 else 0) + + (if (previouslyAttemptedAt.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2800,6 +2878,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3160,6 +3261,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creditNoteNumber.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3347,6 +3472,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3848,7 +3992,7 @@ private constructor( } id() - action() + action().validate() amount() createdAt() creditNote().ifPresent { it.validate() } @@ -3856,10 +4000,37 @@ private constructor( endingBalance() invoice().ifPresent { it.validate() } startingBalance() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNote.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Action @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -3989,6 +4160,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4127,6 +4325,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4270,6 +4484,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4373,6 +4603,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4689,12 +4946,32 @@ private constructor( return@apply } - country() - type() + country().validate() + type().validate() value() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (country.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + class Country @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5239,6 +5516,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Country = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5751,6 +6055,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5876,6 +6207,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7228,6 +7586,45 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (adjustedSubtotal.asKnown().isPresent) 1 else 0) + + (adjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (creditsApplied.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (grouping.asKnown().isPresent) 1 else 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (partiallyInvoicedAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (subLineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (taxAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -7282,8 +7679,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { monetaryUsageDiscount != null -> visitor.visitMonetaryUsageDiscount(monetaryUsageDiscount) monetaryAmountDiscount != null -> @@ -7294,7 +7691,6 @@ private constructor( monetaryMaximum != null -> visitor.visitMonetaryMaximum(monetaryMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -7339,6 +7735,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMonetaryUsageDiscount( + monetaryUsageDiscount: MonetaryUsageDiscountAdjustment + ) = monetaryUsageDiscount.validity() + + override fun visitMonetaryAmountDiscount( + monetaryAmountDiscount: MonetaryAmountDiscountAdjustment + ) = monetaryAmountDiscount.validity() + + override fun visitMonetaryPercentageDiscount( + monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment + ) = monetaryPercentageDiscount.validity() + + override fun visitMonetaryMinimum( + monetaryMinimum: MonetaryMinimumAdjustment + ) = monetaryMinimum.validity() + + override fun visitMonetaryMaximum( + monetaryMaximum: MonetaryMaximumAdjustment + ) = monetaryMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7435,48 +7873,38 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - monetaryUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - monetaryAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - monetaryPercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryPercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - monetaryMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(monetaryMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - monetaryMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(monetaryMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -7916,7 +8344,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -7925,6 +8353,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8014,6 +8466,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8453,7 +8933,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() amountDiscount() appliesToPriceIds() @@ -8462,6 +8942,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8551,6 +9055,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8991,7 +9523,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -9000,6 +9532,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -9089,6 +9645,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9566,7 +10150,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -9576,6 +10160,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -9665,6 +10274,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10103,7 +10740,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -10112,6 +10749,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -10201,6 +10862,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10434,6 +11123,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10653,6 +11361,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10701,14 +11428,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { matrix != null -> visitor.visitMatrix(matrix) tier != null -> visitor.visitTier(tier) other != null -> visitor.visitOther(other) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -10735,6 +11461,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMatrix(matrix: MatrixSubLineItem) = matrix.validity() + + override fun visitTier(tier: TierSubLineItem) = tier.validity() + + override fun visitOther(other: OtherSubLineItem) = other.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10798,22 +11552,19 @@ private constructor( when (type) { "matrix" -> { - return SubLineItem( - matrix = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(matrix = it, _json = json) + } ?: SubLineItem(_json = json) } "tier" -> { - return SubLineItem( - tier = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(tier = it, _json = json) + } ?: SubLineItem(_json = json) } "'null'" -> { - return SubLineItem( - other = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(other = it, _json = json) + } ?: SubLineItem(_json = json) } } @@ -11156,10 +11907,33 @@ private constructor( matrixConfig().validate() name() quantity() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -11330,6 +12104,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11502,6 +12295,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11606,6 +12419,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11953,10 +12794,33 @@ private constructor( name() quantity() tierConfig().validate() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (tierConfig.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -12127,6 +12991,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12368,6 +13251,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12472,6 +13375,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12779,10 +13710,32 @@ private constructor( grouping().ifPresent { it.validate() } name() quantity() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -12953,6 +13906,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13057,6 +14029,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13315,6 +14315,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (taxRateDescription.asKnown().isPresent) 1 else 0) + + (if (taxRatePercentage.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13542,6 +14562,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13631,6 +14670,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13839,6 +14896,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14194,12 +15270,35 @@ private constructor( id() amount() createdAt() - paymentProvider() + paymentProvider().ifPresent { it.validate() } paymentProviderId() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (if (succeeded.asKnown().isPresent) 1 else 0) + /** The payment provider that attempted to collect the payment. */ class PaymentProvider @JsonCreator @@ -14285,6 +15384,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14620,6 +15746,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14740,6 +15889,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14871,6 +16047,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 7223be93..b7eec146 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -1139,6 +1139,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (if (invoiceDate.asKnown().isPresent) 1 else 0) + + (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (willAutoIssue.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1492,7 +1519,7 @@ private constructor( endDate() itemId() - modelType() + modelType().validate() name() quantity() startDate() @@ -1500,6 +1527,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1583,6 +1634,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1731,6 +1809,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1838,6 +1933,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index bc5ee923..e404d4f8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -2144,7 +2144,7 @@ private constructor( hostedInvoiceUrl() invoiceNumber() invoicePdf() - invoiceSource() + invoiceSource().validate() issueFailedAt() issuedAt() lineItems().forEach { it.validate() } @@ -2160,7 +2160,7 @@ private constructor( paymentStartedAt() scheduledIssueAt() shippingAddress().ifPresent { it.validate() } - status() + status().validate() subscription().ifPresent { it.validate() } subtotal() syncFailedAt() @@ -2171,6 +2171,63 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amountDue.asKnown().isPresent) 1 else 0) + + (autoCollection.asKnown().getOrNull()?.validity() ?: 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (customerBalanceTransactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (customerTaxId.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (dueDate.asKnown().isPresent) 1 else 0) + + (if (eligibleToIssueAt.asKnown().isPresent) 1 else 0) + + (if (hostedInvoiceUrl.asKnown().isPresent) 1 else 0) + + (if (invoiceNumber.asKnown().isPresent) 1 else 0) + + (if (invoicePdf.asKnown().isPresent) 1 else 0) + + (invoiceSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (issueFailedAt.asKnown().isPresent) 1 else 0) + + (if (issuedAt.asKnown().isPresent) 1 else 0) + + (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (paidAt.asKnown().isPresent) 1 else 0) + + (paymentAttempts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (paymentFailedAt.asKnown().isPresent) 1 else 0) + + (if (paymentStartedAt.asKnown().isPresent) 1 else 0) + + (if (scheduledIssueAt.asKnown().isPresent) 1 else 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (syncFailedAt.asKnown().isPresent) 1 else 0) + + (if (targetDate.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + (if (willAutoIssue.asKnown().isPresent) 1 else 0) + class AutoCollection private constructor( private val enabled: JsonField, @@ -2472,6 +2529,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (enabled.asKnown().isPresent) 1 else 0) + + (if (nextAttemptAt.asKnown().isPresent) 1 else 0) + + (if (numAttempts.asKnown().isPresent) 1 else 0) + + (if (previouslyAttemptedAt.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2794,6 +2872,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3154,6 +3255,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creditNoteNumber.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3341,6 +3466,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3840,7 +3984,7 @@ private constructor( } id() - action() + action().validate() amount() createdAt() creditNote().ifPresent { it.validate() } @@ -3848,10 +3992,37 @@ private constructor( endingBalance() invoice().ifPresent { it.validate() } startingBalance() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNote.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Action @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -3981,6 +4152,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4119,6 +4317,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4262,6 +4476,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4364,6 +4594,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4680,12 +4937,32 @@ private constructor( return@apply } - country() - type() + country().validate() + type().validate() value() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (country.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + class Country @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5230,6 +5507,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Country = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5742,6 +6046,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5867,6 +6198,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7219,6 +7577,45 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (adjustedSubtotal.asKnown().isPresent) 1 else 0) + + (adjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (creditsApplied.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (grouping.asKnown().isPresent) 1 else 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (partiallyInvoicedAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (subLineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (taxAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -7273,8 +7670,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { monetaryUsageDiscount != null -> visitor.visitMonetaryUsageDiscount(monetaryUsageDiscount) monetaryAmountDiscount != null -> @@ -7285,7 +7682,6 @@ private constructor( monetaryMaximum != null -> visitor.visitMonetaryMaximum(monetaryMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -7330,6 +7726,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMonetaryUsageDiscount( + monetaryUsageDiscount: MonetaryUsageDiscountAdjustment + ) = monetaryUsageDiscount.validity() + + override fun visitMonetaryAmountDiscount( + monetaryAmountDiscount: MonetaryAmountDiscountAdjustment + ) = monetaryAmountDiscount.validity() + + override fun visitMonetaryPercentageDiscount( + monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment + ) = monetaryPercentageDiscount.validity() + + override fun visitMonetaryMinimum( + monetaryMinimum: MonetaryMinimumAdjustment + ) = monetaryMinimum.validity() + + override fun visitMonetaryMaximum( + monetaryMaximum: MonetaryMaximumAdjustment + ) = monetaryMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7426,48 +7864,38 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - monetaryUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - monetaryAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - monetaryPercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryPercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - monetaryMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(monetaryMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - monetaryMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(monetaryMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -7907,7 +8335,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -7916,6 +8344,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8005,6 +8457,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8444,7 +8924,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() amountDiscount() appliesToPriceIds() @@ -8453,6 +8933,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8542,6 +9046,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8982,7 +9514,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -8991,6 +9523,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -9080,6 +9636,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9557,7 +10141,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -9567,6 +10151,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -9656,6 +10265,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10094,7 +10731,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -10103,6 +10740,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -10192,6 +10853,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10425,6 +11114,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10644,6 +11352,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10692,14 +11419,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { matrix != null -> visitor.visitMatrix(matrix) tier != null -> visitor.visitTier(tier) other != null -> visitor.visitOther(other) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -10726,6 +11452,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMatrix(matrix: MatrixSubLineItem) = matrix.validity() + + override fun visitTier(tier: TierSubLineItem) = tier.validity() + + override fun visitOther(other: OtherSubLineItem) = other.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10789,22 +11543,19 @@ private constructor( when (type) { "matrix" -> { - return SubLineItem( - matrix = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(matrix = it, _json = json) + } ?: SubLineItem(_json = json) } "tier" -> { - return SubLineItem( - tier = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(tier = it, _json = json) + } ?: SubLineItem(_json = json) } "'null'" -> { - return SubLineItem( - other = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(other = it, _json = json) + } ?: SubLineItem(_json = json) } } @@ -11147,10 +11898,33 @@ private constructor( matrixConfig().validate() name() quantity() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -11321,6 +12095,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11493,6 +12286,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11597,6 +12410,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11944,10 +12785,33 @@ private constructor( name() quantity() tierConfig().validate() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (tierConfig.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -12118,6 +12982,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12359,6 +13242,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12463,6 +13366,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12770,10 +13701,32 @@ private constructor( grouping().ifPresent { it.validate() } name() quantity() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -12944,6 +13897,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13048,6 +14020,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13306,6 +14306,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (taxRateDescription.asKnown().isPresent) 1 else 0) + + (if (taxRatePercentage.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13533,6 +14553,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13622,6 +14661,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13830,6 +14887,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14185,12 +15261,35 @@ private constructor( id() amount() createdAt() - paymentProvider() + paymentProvider().ifPresent { it.validate() } paymentProviderId() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (if (succeeded.asKnown().isPresent) 1 else 0) + /** The payment provider that attempted to collect the payment. */ class PaymentProvider @JsonCreator @@ -14276,6 +15375,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14611,6 +15737,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14731,6 +15880,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14862,6 +16038,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt index 4dc40971..9285354b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt @@ -382,6 +382,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (synchronous.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt index 76dbc4c4..bdf19bc7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt @@ -48,14 +48,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { percentage != null -> visitor.visitPercentage(percentage) amount != null -> visitor.visitAmount(amount) trial != null -> visitor.visitTrial(trial) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -82,6 +81,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentage(percentage: PercentageDiscount) = percentage.validity() + + override fun visitAmount(amount: AmountDiscount) = amount.validity() + + override fun visitTrial(trial: TrialDiscount) = trial.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -149,22 +175,19 @@ private constructor( when (discountType) { "percentage" -> { - return InvoiceLevelDiscount( - percentage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceLevelDiscount(percentage = it, _json = json) + } ?: InvoiceLevelDiscount(_json = json) } "amount" -> { - return InvoiceLevelDiscount( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceLevelDiscount(amount = it, _json = json) + } ?: InvoiceLevelDiscount(_json = json) } "trial" -> { - return InvoiceLevelDiscount( - trial = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceLevelDiscount(trial = it, _json = json) + } ?: InvoiceLevelDiscount(_json = json) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt index a3df4561..10c28bd6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt @@ -694,6 +694,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (invoiceId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index 56b2e6df..aacfb647 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -1326,6 +1326,44 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (adjustedSubtotal.asKnown().isPresent) 1 else 0) + + (adjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (creditsApplied.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (grouping.asKnown().isPresent) 1 else 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (partiallyInvoicedAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (subLineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (taxAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1380,8 +1418,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { monetaryUsageDiscount != null -> visitor.visitMonetaryUsageDiscount(monetaryUsageDiscount) monetaryAmountDiscount != null -> @@ -1392,7 +1430,6 @@ private constructor( monetaryMaximum != null -> visitor.visitMonetaryMaximum(monetaryMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1433,6 +1470,46 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMonetaryUsageDiscount( + monetaryUsageDiscount: MonetaryUsageDiscountAdjustment + ) = monetaryUsageDiscount.validity() + + override fun visitMonetaryAmountDiscount( + monetaryAmountDiscount: MonetaryAmountDiscountAdjustment + ) = monetaryAmountDiscount.validity() + + override fun visitMonetaryPercentageDiscount( + monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment + ) = monetaryPercentageDiscount.validity() + + override fun visitMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment) = + monetaryMinimum.validity() + + override fun visitMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment) = + monetaryMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1526,48 +1603,38 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - monetaryUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - monetaryAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - monetaryPercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(monetaryPercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - monetaryMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(monetaryMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - monetaryMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(monetaryMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2001,7 +2068,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -2010,6 +2077,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2098,6 +2189,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2533,7 +2651,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() amountDiscount() appliesToPriceIds() @@ -2542,6 +2660,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2630,6 +2772,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3065,7 +3234,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -3074,6 +3243,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3162,6 +3355,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3631,7 +3851,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -3641,6 +3861,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3729,6 +3974,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4160,7 +4432,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amount() appliesToPriceIds() isInvoiceLevel() @@ -4169,6 +4441,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4257,6 +4553,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4482,6 +4805,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4693,6 +5035,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4741,14 +5102,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { matrix != null -> visitor.visitMatrix(matrix) tier != null -> visitor.visitTier(tier) other != null -> visitor.visitOther(other) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -4775,6 +5135,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMatrix(matrix: MatrixSubLineItem) = matrix.validity() + + override fun visitTier(tier: TierSubLineItem) = tier.validity() + + override fun visitOther(other: OtherSubLineItem) = other.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4838,22 +5226,19 @@ private constructor( when (type) { "matrix" -> { - return SubLineItem( - matrix = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(matrix = it, _json = json) + } ?: SubLineItem(_json = json) } "tier" -> { - return SubLineItem( - tier = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(tier = it, _json = json) + } ?: SubLineItem(_json = json) } "'null'" -> { - return SubLineItem( - other = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(other = it, _json = json) + } ?: SubLineItem(_json = json) } } @@ -5188,10 +5573,33 @@ private constructor( matrixConfig().validate() name() quantity() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -5358,6 +5766,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5527,6 +5954,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5629,6 +6076,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5969,10 +6443,33 @@ private constructor( name() quantity() tierConfig().validate() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (tierConfig.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -6139,6 +6636,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6377,6 +6893,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6479,6 +7015,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6779,10 +7342,32 @@ private constructor( grouping().ifPresent { it.validate() } name() quantity() - type() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (grouping.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + class Grouping private constructor( private val key: JsonField, @@ -6949,6 +7534,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7051,6 +7655,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7300,6 +7931,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (taxRateDescription.asKnown().isPresent) 1 else 0) + + (if (taxRatePercentage.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt index e47e79c8..9fa3ef0b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.InvoiceService import java.util.Collections import java.util.Objects @@ -139,6 +140,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt index 08ed498f..197ba25b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.InvoiceServiceAsync import java.util.Collections import java.util.Objects @@ -144,6 +145,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt index c4f2cb8b..646aa71a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt @@ -564,6 +564,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DateType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -679,6 +706,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt index 997190ca..b59b8a09 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt @@ -527,6 +527,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (paymentReceivedDate.asKnown().isPresent) 1 else 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (if (notes.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index f6bfa3ff..1c75cce6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -379,6 +379,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -468,6 +485,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt index a3825e46..9427b12f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -18,6 +18,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull /** * The Item resource represents a sellable product or good. Items are associated with all line @@ -264,6 +265,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (externalConnections.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + class ExternalConnection private constructor( private val externalConnectionName: JsonField, @@ -430,11 +451,30 @@ private constructor( return@apply } - externalConnectionName() + externalConnectionName().validate() externalEntityId() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (externalConnectionName.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalEntityId.asKnown().isPresent) 1 else 0) + class ExternalConnectionName @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -557,6 +597,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExternalConnectionName = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt index f138325e..edf87054 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt @@ -347,6 +347,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt index be1b3087..6540323e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.ItemService import java.util.Collections import java.util.Objects @@ -126,6 +127,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt index 99e19c55..e9f51fd1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.ItemServiceAsync import java.util.Collections import java.util.Objects @@ -128,6 +129,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index 572867a1..6dc9691a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -467,6 +467,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (externalConnections.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -651,11 +670,30 @@ private constructor( return@apply } - externalConnectionName() + externalConnectionName().validate() externalEntityId() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (externalConnectionName.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalEntityId.asKnown().isPresent) 1 else 0) + class ExternalConnectionName @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -778,6 +816,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExternalConnectionName = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt index 2857173a..8a5d857c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt @@ -644,6 +644,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (sql.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -733,6 +755,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt index d1fdbb10..4461feb6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.MetricService import java.util.Collections import java.util.Objects @@ -129,6 +130,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt index d01f0883..e0527090 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.MetricServiceAsync import java.util.Collections import java.util.Objects @@ -131,6 +132,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt index deac841b..7a5daa6b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt @@ -377,6 +377,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -466,6 +483,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt index fb247bc2..480a832e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt @@ -174,6 +174,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (hasMore.asKnown().isPresent) 1 else 0) + (if (nextCursor.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt index 8c043254..f92d976b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt @@ -275,12 +275,32 @@ private constructor( } appliesToPriceIds() - discountType() + discountType().validate() percentageDiscount() reason() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -362,6 +382,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt index f8a41c0a..baa6c2a0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -1325,12 +1325,52 @@ private constructor( planPhases().ifPresent { it.forEach { it.validate() } } prices().forEach { it.validate() } product().validate() - status() + status().validate() trialConfig().validate() version() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (basePlan.asKnown().getOrNull()?.validity() ?: 0) + + (if (basePlanId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (if (invoicingCurrency.asKnown().isPresent) 1 else 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (planPhases.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (prices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (version.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1385,8 +1425,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1397,7 +1437,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1442,6 +1481,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1536,48 +1617,38 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2032,7 +2103,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2041,6 +2112,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2129,6 +2224,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2583,7 +2705,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -2592,6 +2714,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2680,6 +2826,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3134,7 +3307,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3143,6 +3316,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3231,6 +3428,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3719,7 +3943,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -3729,6 +3953,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3817,6 +4066,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4267,7 +4543,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4276,6 +4552,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4364,6 +4664,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4609,6 +4936,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4818,6 +5165,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4907,6 +5273,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5115,6 +5499,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5687,7 +6090,7 @@ private constructor( description() discount().ifPresent { it.validate() } duration() - durationUnit() + durationUnit().ifPresent { it.validate() } maximum().ifPresent { it.validate() } maximumAmount() minimum().ifPresent { it.validate() } @@ -5697,6 +6100,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (order.asKnown().isPresent) 1 else 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5804,6 +6235,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6016,6 +6474,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6233,6 +6710,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6460,6 +6956,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6568,6 +7084,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6753,10 +7296,29 @@ private constructor( } trialPeriod() - trialPeriodUnit() + trialPeriodUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (trialPeriod.asKnown().isPresent) 1 else 0) + + (trialPeriodUnit.asKnown().getOrNull()?.validity() ?: 0) + class TrialPeriodUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6841,6 +7403,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TrialPeriodUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 4a3a3455..402d2ad2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1263,10 +1263,35 @@ private constructor( externalPlanId() metadata().ifPresent { it.validate() } netTerms() - status() + status().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (prices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1518,8 +1543,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newPlanUnit != null -> visitor.visitNewPlanUnit(newPlanUnit) newPlanPackage != null -> visitor.visitNewPlanPackage(newPlanPackage) newPlanMatrix != null -> visitor.visitNewPlanMatrix(newPlanMatrix) @@ -1570,7 +1595,6 @@ private constructor( visitor.visitNewPlanCumulativeGroupedBulk(newPlanCumulativeGroupedBulk) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1721,6 +1745,122 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewPlanUnit(newPlanUnit: NewPlanUnitPrice) = + newPlanUnit.validity() + + override fun visitNewPlanPackage(newPlanPackage: NewPlanPackagePrice) = + newPlanPackage.validity() + + override fun visitNewPlanMatrix(newPlanMatrix: NewPlanMatrixPrice) = + newPlanMatrix.validity() + + override fun visitNewPlanTiered(newPlanTiered: NewPlanTieredPrice) = + newPlanTiered.validity() + + override fun visitNewPlanTieredBps(newPlanTieredBps: NewPlanTieredBpsPrice) = + newPlanTieredBps.validity() + + override fun visitNewPlanBps(newPlanBps: NewPlanBpsPrice) = + newPlanBps.validity() + + override fun visitNewPlanBulkBps(newPlanBulkBps: NewPlanBulkBpsPrice) = + newPlanBulkBps.validity() + + override fun visitNewPlanBulk(newPlanBulk: NewPlanBulkPrice) = + newPlanBulk.validity() + + override fun visitNewPlanThresholdTotalAmount( + newPlanThresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = newPlanThresholdTotalAmount.validity() + + override fun visitNewPlanTieredPackage( + newPlanTieredPackage: NewPlanTieredPackagePrice + ) = newPlanTieredPackage.validity() + + override fun visitNewPlanTieredWithMinimum( + newPlanTieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = newPlanTieredWithMinimum.validity() + + override fun visitNewPlanUnitWithPercent( + newPlanUnitWithPercent: NewPlanUnitWithPercentPrice + ) = newPlanUnitWithPercent.validity() + + override fun visitNewPlanPackageWithAllocation( + newPlanPackageWithAllocation: NewPlanPackageWithAllocationPrice + ) = newPlanPackageWithAllocation.validity() + + override fun visitNewPlanTierWithProration( + newPlanTierWithProration: NewPlanTierWithProrationPrice + ) = newPlanTierWithProration.validity() + + override fun visitNewPlanUnitWithProration( + newPlanUnitWithProration: NewPlanUnitWithProrationPrice + ) = newPlanUnitWithProration.validity() + + override fun visitNewPlanGroupedAllocation( + newPlanGroupedAllocation: NewPlanGroupedAllocationPrice + ) = newPlanGroupedAllocation.validity() + + override fun visitNewPlanGroupedWithProratedMinimum( + newPlanGroupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = newPlanGroupedWithProratedMinimum.validity() + + override fun visitNewPlanGroupedWithMeteredMinimum( + newPlanGroupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = newPlanGroupedWithMeteredMinimum.validity() + + override fun visitNewPlanMatrixWithDisplayName( + newPlanMatrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = newPlanMatrixWithDisplayName.validity() + + override fun visitNewPlanBulkWithProration( + newPlanBulkWithProration: NewPlanBulkWithProrationPrice + ) = newPlanBulkWithProration.validity() + + override fun visitNewPlanGroupedTieredPackage( + newPlanGroupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = newPlanGroupedTieredPackage.validity() + + override fun visitNewPlanMaxGroupTieredPackage( + newPlanMaxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = newPlanMaxGroupTieredPackage.validity() + + override fun visitNewPlanScalableMatrixWithUnitPricing( + newPlanScalableMatrixWithUnitPricing: + NewPlanScalableMatrixWithUnitPricingPrice + ) = newPlanScalableMatrixWithUnitPricing.validity() + + override fun visitNewPlanScalableMatrixWithTieredPricing( + newPlanScalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = newPlanScalableMatrixWithTieredPricing.validity() + + override fun visitNewPlanCumulativeGroupedBulk( + newPlanCumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = newPlanCumulativeGroupedBulk.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2003,204 +2143,160 @@ private constructor( when (modelType) { "unit" -> { - return Price( - newPlanUnit = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(newPlanUnit = it, _json = json) + } ?: Price(_json = json) } "package" -> { - return Price( - newPlanPackage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(newPlanPackage = it, _json = json) + } ?: Price(_json = json) } "matrix" -> { - return Price( - newPlanMatrix = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(newPlanMatrix = it, _json = json) + } ?: Price(_json = json) } "tiered" -> { - return Price( - newPlanTiered = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(newPlanTiered = it, _json = json) + } ?: Price(_json = json) } "tiered_bps" -> { - return Price( - newPlanTieredBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(newPlanTieredBps = it, _json = json) + } ?: Price(_json = json) } "bps" -> { - return Price( - newPlanBps = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(newPlanBps = it, _json = json) + } ?: Price(_json = json) } "bulk_bps" -> { - return Price( - newPlanBulkBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(newPlanBulkBps = it, _json = json) + } ?: Price(_json = json) } "bulk" -> { - return Price( - newPlanBulk = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(newPlanBulk = it, _json = json) + } ?: Price(_json = json) } "threshold_total_amount" -> { - return Price( - newPlanThresholdTotalAmount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanThresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } "tiered_package" -> { - return Price( - newPlanTieredPackage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newPlanTieredPackage = it, _json = json) } + ?: Price(_json = json) } "tiered_with_minimum" -> { - return Price( - newPlanTieredWithMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newPlanTieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } "unit_with_percent" -> { - return Price( - newPlanUnitWithPercent = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newPlanUnitWithPercent = it, _json = json) } + ?: Price(_json = json) } "package_with_allocation" -> { - return Price( - newPlanPackageWithAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanPackageWithAllocation = it, _json = json) } + ?: Price(_json = json) } "tiered_with_proration" -> { - return Price( - newPlanTierWithProration = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newPlanTierWithProration = it, _json = json) } + ?: Price(_json = json) } "unit_with_proration" -> { - return Price( - newPlanUnitWithProration = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newPlanUnitWithProration = it, _json = json) } + ?: Price(_json = json) } "grouped_allocation" -> { - return Price( - newPlanGroupedAllocation = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newPlanGroupedAllocation = it, _json = json) } + ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return Price( - newPlanGroupedWithProratedMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanGroupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return Price( - newPlanGroupedWithMeteredMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanGroupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } "matrix_with_display_name" -> { - return Price( - newPlanMatrixWithDisplayName = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanMatrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } "bulk_with_proration" -> { - return Price( - newPlanBulkWithProration = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newPlanBulkWithProration = it, _json = json) } + ?: Price(_json = json) } "grouped_tiered_package" -> { - return Price( - newPlanGroupedTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanGroupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } "max_group_tiered_package" -> { - return Price( - newPlanMaxGroupTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanMaxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return Price( - newPlanScalableMatrixWithUnitPricing = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanScalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return Price( - newPlanScalableMatrixWithTieredPricing = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newPlanScalableMatrixWithTieredPricing = it, _json = json) + } ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return Price( - newPlanCumulativeGroupedBulk = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newPlanCumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } } @@ -3081,9 +3177,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitConfig().validate() billableMetricId() @@ -3099,6 +3195,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3215,6 +3343,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3313,6 +3468,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3461,6 +3643,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3658,10 +3857,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -3758,6 +3976,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3969,10 +4215,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -4069,6 +4334,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4174,6 +4467,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5027,9 +5340,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageConfig().validate() billableMetricId() @@ -5045,6 +5358,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5161,6 +5506,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5259,6 +5631,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5455,6 +5854,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5652,10 +6070,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -5752,6 +6189,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5963,10 +6428,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -6063,6 +6547,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6168,6 +6680,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7021,10 +7553,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -7039,6 +7571,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -7155,6 +7719,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7419,6 +8010,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -7621,6 +8234,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7742,6 +8375,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7934,10 +8594,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -8034,6 +8713,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8245,10 +8952,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -8345,6 +9071,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8450,6 +9204,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9303,9 +10077,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredConfig().validate() billableMetricId() @@ -9321,6 +10095,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -9437,6 +10243,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9535,6 +10368,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9693,6 +10553,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val firstUnit: JsonField, @@ -9925,6 +10803,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10140,10 +11038,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -10240,6 +11157,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10451,10 +11396,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -10551,6 +11515,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10656,6 +11648,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11511,9 +12523,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredBpsConfig().validate() billableMetricId() @@ -11529,6 +12541,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -11645,6 +12689,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11743,6 +12814,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11905,6 +13003,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -12179,6 +13295,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12394,10 +13531,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -12494,6 +13650,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12705,10 +13889,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -12805,6 +14008,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12910,6 +14141,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13763,9 +15014,9 @@ private constructor( } bpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -13780,6 +15031,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BpsConfig private constructor( private val bps: JsonField, @@ -13957,6 +15240,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14091,6 +15393,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14189,6 +15518,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14381,10 +15737,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -14481,6 +15856,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14692,10 +16095,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -14792,6 +16214,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14897,6 +16347,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15751,9 +17221,9 @@ private constructor( } bulkBpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -15768,6 +17238,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkBpsConfig private constructor( private val tiers: JsonField>, @@ -15917,6 +17419,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -16147,6 +17667,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16299,6 +17839,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16397,6 +17964,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16589,10 +18183,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -16689,6 +18302,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16900,10 +18541,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -17000,6 +18660,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17105,6 +18793,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17958,9 +19666,9 @@ private constructor( } bulkConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -17975,6 +19683,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkConfig private constructor( private val tiers: JsonField>, @@ -18120,6 +19860,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val unitAmount: JsonField, @@ -18313,6 +20071,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (maximumUnits.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18465,6 +20242,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18563,6 +20367,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18755,10 +20586,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -18855,6 +20705,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19066,10 +20944,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -19166,6 +21063,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19271,6 +21196,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20136,9 +22081,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -20154,6 +22099,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -20270,6 +22247,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20368,6 +22372,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20456,6 +22487,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20653,10 +22704,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -20753,6 +22823,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20964,10 +23062,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -21064,6 +23181,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21169,6 +23314,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22027,9 +24192,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredPackageConfig().validate() billableMetricId() @@ -22045,6 +24210,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -22161,6 +24358,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22259,6 +24483,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22346,6 +24597,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22543,10 +24814,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -22643,6 +24933,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22854,10 +25172,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -22954,6 +25291,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23059,6 +25424,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23920,9 +26305,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithMinimumConfig().validate() billableMetricId() @@ -23938,6 +26323,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -24054,6 +26471,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24152,6 +26596,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24239,6 +26710,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24436,10 +26927,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24536,6 +27046,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24747,10 +27285,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24847,6 +27404,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24952,6 +27537,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25812,9 +28417,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithPercentConfig().validate() billableMetricId() @@ -25830,6 +28435,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -25946,6 +28583,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26044,6 +28708,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26131,6 +28822,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26328,10 +29039,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26428,6 +29158,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26639,10 +29397,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26739,6 +29516,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26844,6 +29649,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27709,9 +30534,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageWithAllocationConfig().validate() billableMetricId() @@ -27727,6 +30552,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -27843,6 +30700,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27941,6 +30825,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28029,6 +30940,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28226,10 +31157,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28326,6 +31276,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28537,10 +31515,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28637,6 +31634,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28742,6 +31767,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29604,9 +32649,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithProrationConfig().validate() billableMetricId() @@ -29622,6 +32667,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -29738,6 +32815,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29836,6 +32940,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29924,6 +33055,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30121,10 +33272,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30221,6 +33391,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30432,10 +33630,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30532,6 +33749,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30637,6 +33882,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31498,9 +34763,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithProrationConfig().validate() billableMetricId() @@ -31516,6 +34781,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -31632,6 +34929,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31730,6 +35054,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31817,6 +35168,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32014,10 +35385,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32114,6 +35504,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32325,10 +35743,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32425,6 +35862,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32530,6 +35995,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33391,10 +36876,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedAllocationConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -33409,6 +36894,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -33525,6 +37042,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33612,6 +37156,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33715,6 +37279,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33907,10 +37498,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34007,6 +37617,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34218,10 +37856,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34318,6 +37975,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34423,6 +38108,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35295,10 +39000,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -35313,6 +39018,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -35429,6 +39166,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35518,6 +39282,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35622,6 +39406,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35814,10 +39625,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -35914,6 +39744,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36125,10 +39983,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -36225,6 +40102,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36330,6 +40235,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37199,10 +41124,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -37217,6 +41142,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -37333,6 +41290,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37422,6 +41406,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37525,6 +41529,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37717,10 +41748,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -37817,6 +41867,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38028,10 +42106,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -38128,6 +42225,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38233,6 +42358,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39098,10 +43243,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -39116,6 +43261,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -39232,6 +43409,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39320,6 +43524,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39423,6 +43647,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39615,10 +43866,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -39715,6 +43985,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39926,10 +44224,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -40026,6 +44343,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40131,6 +44476,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40993,9 +45358,9 @@ private constructor( } bulkWithProrationConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -41010,6 +45375,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkWithProrationConfig @JsonCreator private constructor( @@ -41084,6 +45481,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41218,6 +45635,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41316,6 +45760,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41508,10 +45979,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -41608,6 +46098,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41819,10 +46337,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -41919,6 +46456,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42024,6 +46589,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42889,10 +47474,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -42907,6 +47492,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -43023,6 +47640,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43111,6 +47755,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43214,6 +47878,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43406,10 +48097,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -43506,6 +48216,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43717,10 +48455,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -43817,6 +48574,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43922,6 +48707,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44787,10 +49592,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -44805,6 +49610,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -44921,6 +49758,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45009,6 +49873,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45112,6 +49996,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45304,10 +50215,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -45404,6 +50334,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45615,10 +50573,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -45715,6 +50692,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45820,6 +50825,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46704,9 +51729,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -46722,6 +51747,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -46838,6 +51895,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46937,6 +52021,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47026,6 +52137,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47223,10 +52354,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -47323,6 +52473,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47534,10 +52712,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -47634,6 +52831,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47739,6 +52964,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48625,9 +53870,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -48643,6 +53888,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -48759,6 +54036,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48861,6 +54165,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48951,6 +54282,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49148,10 +54499,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -49248,6 +54618,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49459,10 +54857,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -49559,6 +54976,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49664,6 +55109,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50529,10 +55994,10 @@ private constructor( return@apply } - cadence() + cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -50547,6 +56012,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -50663,6 +56160,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50751,6 +56275,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50854,6 +56398,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51046,10 +56617,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -51146,6 +56736,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51357,10 +56975,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -51457,6 +57094,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51562,6 +57227,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51669,6 +57354,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51774,6 +57477,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt index 5503bea7..0b54c51b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt @@ -470,6 +470,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -559,6 +578,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt index 51c3c4e7..0bfc854e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.PlanService import java.util.Collections import java.util.Objects @@ -131,6 +132,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt index f0284c21..77a907d1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.PlanServiceAsync import java.util.Collections import java.util.Objects @@ -133,6 +134,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt index a56974b5..25dc0e92 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt @@ -378,6 +378,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt index e9c61454..535a74f5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt @@ -467,6 +467,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -556,6 +575,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt index e1d5c45a..24baca70 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -282,8 +282,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { unit != null -> visitor.visitUnit(unit) packagePrice != null -> visitor.visitPackagePrice(packagePrice) matrix != null -> visitor.visitMatrix(matrix) @@ -323,7 +323,6 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -476,6 +475,116 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: UnitPrice) = unit.validity() + + override fun visitPackagePrice(packagePrice: PackagePrice) = packagePrice.validity() + + override fun visitMatrix(matrix: MatrixPrice) = matrix.validity() + + override fun visitTiered(tiered: TieredPrice) = tiered.validity() + + override fun visitTieredBps(tieredBps: TieredBpsPrice) = tieredBps.validity() + + override fun visitBps(bps: BpsPrice) = bps.validity() + + override fun visitBulkBps(bulkBps: BulkBpsPrice) = bulkBps.validity() + + override fun visitBulk(bulk: BulkPrice) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackagePrice) = + tieredPackage.validity() + + override fun visitGroupedTiered(groupedTiered: GroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimumPrice) = + tieredWithMinimum.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercentPrice) = + unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProrationPrice + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProrationPrice) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocationPrice) = + groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProrationPrice) = + bulkWithProration.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -719,189 +828,150 @@ private constructor( when (modelType) { "unit" -> { - return Price( - unit = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } "package" -> { - return Price( - packagePrice = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(packagePrice = it, _json = json) + } ?: Price(_json = json) } "matrix" -> { - return Price( - matrix = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) } "tiered" -> { - return Price( - tiered = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } "tiered_bps" -> { - return Price( - tieredBps = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredBps = it, _json = json) + } ?: Price(_json = json) } "bps" -> { - return Price(bps = deserialize(node, jacksonTypeRef()), _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bps = it, _json = json) + } ?: Price(_json = json) } "bulk_bps" -> { - return Price( - bulkBps = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkBps = it, _json = json) + } ?: Price(_json = json) } "bulk" -> { - return Price( - bulk = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } "threshold_total_amount" -> { - return Price( - thresholdTotalAmount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(thresholdTotalAmount = it, _json = json) + } ?: Price(_json = json) } "tiered_package" -> { - return Price( - tieredPackage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredPackage = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered" -> { - return Price( - groupedTiered = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedTiered = it, _json = json) + } ?: Price(_json = json) } "tiered_with_minimum" -> { - return Price( - tieredWithMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithMinimum = it, _json = json) + } ?: Price(_json = json) } "tiered_package_with_minimum" -> { - return Price( - tieredPackageWithMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) } "package_with_allocation" -> { - return Price( - packageWithAllocation = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(packageWithAllocation = it, _json = json) + } ?: Price(_json = json) } "unit_with_percent" -> { - return Price( - unitWithPercent = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithPercent = it, _json = json) + } ?: Price(_json = json) } "matrix_with_allocation" -> { - return Price( - matrixWithAllocation = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrixWithAllocation = it, _json = json) + } ?: Price(_json = json) } "tiered_with_proration" -> { - return Price( - tieredWithProration = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithProration = it, _json = json) + } ?: Price(_json = json) } "unit_with_proration" -> { - return Price( - unitWithProration = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_allocation" -> { - return Price( - groupedAllocation = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedAllocation = it, _json = json) + } ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return Price( - groupedWithProratedMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return Price( - groupedWithMeteredMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } "matrix_with_display_name" -> { - return Price( - matrixWithDisplayName = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrixWithDisplayName = it, _json = json) + } ?: Price(_json = json) } "bulk_with_proration" -> { - return Price( - bulkWithProration = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered_package" -> { - return Price( - groupedTieredPackage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedTieredPackage = it, _json = json) + } ?: Price(_json = json) } "max_group_tiered_package" -> { - return Price( - maxGroupTieredPackage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(maxGroupTieredPackage = it, _json = json) + } ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return Price( - scalableMatrixWithUnitPricing = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return Price( - scalableMatrixWithTieredPricing = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return Price( - cumulativeGroupedBulk = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(cumulativeGroupedBulk = it, _json = json) + } ?: Price(_json = json) } } @@ -2080,7 +2150,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -2095,15 +2165,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() unitConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -2226,6 +2337,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2411,10 +2538,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2508,6 +2654,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2651,6 +2824,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2833,6 +3033,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3019,10 +3238,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3116,6 +3354,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3305,6 +3570,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3522,6 +3805,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3614,6 +3916,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3830,6 +4150,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3931,6 +4270,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4033,6 +4399,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4181,6 +4574,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4391,6 +4801,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5545,7 +5974,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -5560,15 +5989,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() packageConfig().validate() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -5691,6 +6161,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5876,10 +6362,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5973,6 +6478,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6116,6 +6648,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6298,6 +6857,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6484,10 +7062,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6581,6 +7178,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6770,6 +7394,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6987,6 +7629,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7079,6 +7740,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7295,6 +7974,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7396,6 +8094,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7592,6 +8317,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7699,6 +8443,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7904,6 +8675,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9057,7 +9847,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -9073,14 +9863,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -9203,6 +10034,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9388,10 +10235,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -9485,6 +10351,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9628,6 +10521,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9810,6 +10730,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9996,10 +10935,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -10093,6 +11051,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10282,6 +11267,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10549,6 +11552,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { (if (it == null) 0 else 1).toInt() } + ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -10749,6 +11773,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10984,6 +12028,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11076,6 +12139,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11292,6 +12373,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11393,6 +12493,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11495,6 +12622,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11700,6 +12854,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12853,7 +14026,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -12868,15 +14041,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() tieredConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -12999,6 +14213,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13184,10 +14414,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -13281,6 +14530,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13424,6 +14700,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13606,6 +14909,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13792,10 +15114,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -13889,6 +15230,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14078,6 +15446,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14295,6 +15681,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14387,6 +15792,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14603,6 +16026,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14704,6 +16146,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14806,6 +16275,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14963,6 +16459,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val firstUnit: JsonField, @@ -15190,6 +16704,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15418,6 +16952,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16572,7 +18125,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -16587,15 +18140,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() tieredBpsConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -16718,6 +18312,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16903,10 +18513,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -17000,6 +18629,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17143,6 +18799,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17325,6 +19008,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17511,10 +19213,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -17608,6 +19329,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17797,6 +19545,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18014,6 +19780,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18106,6 +19891,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18322,6 +20125,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18423,6 +20245,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18525,6 +20374,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18685,6 +20561,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -18954,6 +20848,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19182,6 +21097,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20333,7 +22267,7 @@ private constructor( billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() bpsConfig().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -20348,14 +22282,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -20478,6 +22453,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20663,10 +22654,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -20760,6 +22770,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20967,6 +23004,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21097,6 +23153,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21279,6 +23362,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21465,10 +23567,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -21562,6 +23683,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21751,6 +23899,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21968,6 +24134,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22060,6 +24245,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22276,6 +24479,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22377,6 +24599,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22479,6 +24728,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22684,6 +24960,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23839,7 +26134,7 @@ private constructor( billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() bulkBpsConfig().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -23854,14 +26149,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -23984,6 +26320,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24169,10 +26521,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -24266,6 +26637,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24445,6 +26843,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -24670,6 +27086,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24818,6 +27254,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25000,6 +27463,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25186,10 +27668,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -25283,6 +27784,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25472,6 +28000,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25689,6 +28235,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25781,6 +28346,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25997,6 +28580,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26098,6 +28700,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26200,6 +28829,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26405,6 +29061,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27558,7 +30233,7 @@ private constructor( billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() bulkConfig().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -27573,14 +30248,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -27703,6 +30419,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27888,10 +30620,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -27985,6 +30736,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28160,6 +30938,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val unitAmount: JsonField, @@ -28350,6 +31146,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (maximumUnits.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28498,6 +31313,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28680,6 +31522,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28866,10 +31727,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -28963,6 +31843,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29152,6 +32059,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29369,6 +32294,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29461,6 +32405,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29677,6 +32639,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29778,6 +32759,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29880,6 +32888,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30085,6 +33120,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31243,7 +34297,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -31258,15 +34312,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() thresholdTotalAmountConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -31389,6 +34484,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31574,10 +34685,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -31671,6 +34801,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31814,6 +34971,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31996,6 +35180,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32182,10 +35385,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -32279,6 +35501,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32468,6 +35717,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32685,6 +35952,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32777,6 +36063,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32993,6 +36297,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33094,6 +36417,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33196,6 +36546,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33283,6 +36660,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33493,6 +36888,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34648,7 +38062,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -34663,15 +38077,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() tieredPackageConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -34794,6 +38249,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34979,10 +38450,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -35076,6 +38566,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35219,6 +38736,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35401,6 +38945,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35587,10 +39150,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -35684,6 +39266,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35873,6 +39482,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36090,6 +39717,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36182,6 +39828,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36398,6 +40062,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36499,6 +40182,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36601,6 +40311,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36686,6 +40423,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36896,6 +40651,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38051,7 +41825,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -38067,14 +41841,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -38197,6 +42012,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38382,10 +42213,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -38479,6 +42329,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38622,6 +42499,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38804,6 +42708,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38894,6 +42817,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39080,10 +43021,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -39177,6 +43137,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39366,6 +43353,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39583,6 +43588,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39675,6 +43699,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39891,6 +43933,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39992,6 +44053,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40094,6 +44182,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40299,6 +44414,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41454,7 +45588,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -41469,15 +45603,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() tieredWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -41600,6 +45775,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41785,10 +45976,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -41882,6 +46092,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42025,6 +46262,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42207,6 +46471,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42393,10 +46676,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -42490,6 +46792,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42679,6 +47008,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42896,6 +47243,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42988,6 +47354,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43204,6 +47588,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43305,6 +47708,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43407,6 +47837,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43494,6 +47951,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43704,6 +48179,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44870,7 +49364,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -44885,15 +49379,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() tieredPackageWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -45016,6 +49551,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45201,10 +49752,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -45298,6 +49868,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45441,6 +50038,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45623,6 +50247,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45809,10 +50452,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -45906,6 +50568,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46095,6 +50784,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46312,6 +51019,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46404,6 +51130,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46620,6 +51364,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46721,6 +51484,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46823,6 +51613,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46911,6 +51728,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47121,6 +51956,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48281,7 +53135,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -48296,15 +53150,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() packageWithAllocationConfig().validate() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -48427,6 +53322,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48612,10 +53523,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -48709,6 +53639,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48852,6 +53809,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49034,6 +54018,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49220,10 +54223,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -49317,6 +54339,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49506,6 +54555,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49723,6 +54790,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49815,6 +54901,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50031,6 +55135,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50132,6 +55255,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50220,6 +55370,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50327,6 +55495,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50532,6 +55727,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51688,7 +56902,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -51703,15 +56917,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() unitWithPercentConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -51834,6 +57089,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52019,10 +57290,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -52116,6 +57406,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52259,6 +57576,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52441,6 +57785,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52627,10 +57990,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -52724,6 +58106,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52913,6 +58322,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53130,6 +58557,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53222,6 +58668,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53438,6 +58902,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53539,6 +59022,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53641,6 +59151,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53727,6 +59264,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53937,6 +59492,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55095,7 +60669,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -55111,14 +60685,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -55241,6 +60856,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55426,10 +61057,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -55523,6 +61173,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55666,6 +61343,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55848,6 +61552,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56034,10 +61757,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -56131,6 +61873,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56320,6 +62089,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56633,6 +62420,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { (if (it == null) 0 else 1).toInt() } + ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -56833,6 +62642,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57068,6 +62897,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57160,6 +63008,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57376,6 +63242,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57477,6 +63362,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57579,6 +63491,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57784,6 +63723,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58941,7 +64899,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -58956,15 +64914,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() tieredWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -59087,6 +65086,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59272,10 +65287,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -59369,6 +65403,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59512,6 +65573,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59694,6 +65782,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59880,10 +65987,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -59977,6 +66103,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60166,6 +66319,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60383,6 +66554,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60475,6 +66665,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60691,6 +66899,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60792,6 +67019,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60894,6 +67148,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60981,6 +67262,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61191,6 +67490,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62346,7 +68664,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -62361,15 +68679,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() unitWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -62492,6 +68851,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62677,10 +69052,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -62774,6 +69168,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62917,6 +69338,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63099,6 +69547,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63285,10 +69752,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63382,6 +69868,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63571,6 +70084,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63788,6 +70319,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63880,6 +70430,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64096,6 +70664,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64197,6 +70784,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64299,6 +70913,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64386,6 +71027,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64596,6 +71255,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -65751,7 +72429,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -65767,14 +72445,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -65897,6 +72616,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66082,10 +72817,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -66179,6 +72933,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66322,6 +73103,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66504,6 +73312,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66596,6 +73423,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66782,10 +73627,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -66879,6 +73743,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67068,6 +73959,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67285,6 +74194,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67377,6 +74305,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67593,6 +74539,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67694,6 +74659,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67796,6 +74788,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -68001,6 +75020,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -69171,7 +76209,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -69187,14 +76225,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -69317,6 +76396,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -69502,10 +76597,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -69599,6 +76713,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -69742,6 +76883,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -69924,6 +77092,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70018,6 +77205,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70204,10 +77409,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -70301,6 +77525,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70490,6 +77741,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70707,6 +77976,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70799,6 +78087,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -71015,6 +78321,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -71116,6 +78441,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -71218,6 +78570,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -71423,6 +78802,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72593,7 +79991,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -72609,14 +80007,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -72739,6 +80178,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72924,10 +80379,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -73021,6 +80495,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73164,6 +80665,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73346,6 +80874,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73440,6 +80987,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73626,10 +81191,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -73723,6 +81307,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73912,6 +81523,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74129,6 +81758,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74221,6 +81869,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74437,6 +82103,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74538,6 +82223,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74640,6 +82352,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74845,6 +82584,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76005,7 +83763,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -76021,14 +83779,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -76151,6 +83950,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76336,10 +84151,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -76433,6 +84267,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76576,6 +84437,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76758,6 +84646,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76944,10 +84851,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -77041,6 +84967,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77230,6 +85183,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77323,6 +85294,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77540,6 +85529,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77632,6 +85640,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77848,6 +85874,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77949,6 +85994,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -78051,6 +86123,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -78256,6 +86355,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79412,7 +87530,7 @@ private constructor( billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() bulkWithProrationConfig().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -79427,14 +87545,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -79557,6 +87716,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79742,10 +87917,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -79839,6 +88033,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79944,6 +88165,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80074,6 +88313,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80256,6 +88522,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80442,10 +88727,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -80539,6 +88843,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80728,6 +89059,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80945,6 +89294,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81037,6 +89405,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81253,6 +89639,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81354,6 +89759,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81456,6 +89888,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81661,6 +90120,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -82819,7 +91297,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -82835,14 +91313,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -82965,6 +91484,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83150,10 +91685,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -83247,6 +91801,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83390,6 +91971,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83572,6 +92180,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83664,6 +92291,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83850,10 +92495,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -83947,6 +92611,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84136,6 +92827,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84353,6 +93062,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84445,6 +93173,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84661,6 +93407,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84762,6 +93527,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84864,6 +93656,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -85069,6 +93888,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86229,7 +95067,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -86245,14 +95083,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -86375,6 +95254,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86560,10 +95455,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -86657,6 +95571,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86800,6 +95741,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86982,6 +95950,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87168,10 +96155,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -87265,6 +96271,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87454,6 +96487,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87547,6 +96598,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87764,6 +96833,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87856,6 +96944,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88072,6 +97178,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88173,6 +97298,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88275,6 +97427,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88480,6 +97659,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -89659,7 +98857,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -89674,15 +98872,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -89805,6 +99044,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -89990,10 +99245,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -90087,6 +99361,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90230,6 +99531,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90412,6 +99740,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90598,10 +99945,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -90695,6 +100061,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90884,6 +100277,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91101,6 +100512,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91193,6 +100623,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91409,6 +100857,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91511,6 +100978,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91613,6 +101107,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91702,6 +101223,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91912,6 +101451,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93093,7 +102651,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -93108,15 +102666,56 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -93239,6 +102838,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93424,10 +103039,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -93521,6 +103155,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93664,6 +103325,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93846,6 +103534,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94032,10 +103739,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -94129,6 +103855,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94318,6 +104071,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94535,6 +104306,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94627,6 +104417,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94843,6 +104651,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94945,6 +104772,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95047,6 +104901,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95136,6 +105017,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95346,6 +105245,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -96506,7 +106424,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - cadence() + cadence().validate() conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } @@ -96522,14 +106440,55 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType() + modelType().validate() name() planPhaseOrder() - priceType() + priceType().validate() dimensionalPriceConfiguration().ifPresent { 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -96652,6 +106611,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -96837,10 +106812,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -96934,6 +106928,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97077,6 +107098,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97259,6 +107307,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowsRollover.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97352,6 +107419,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97538,10 +107623,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -97635,6 +107739,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97824,6 +107955,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98041,6 +108190,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98133,6 +108301,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98349,6 +108535,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98450,6 +108655,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98552,6 +108784,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98757,6 +109016,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.size ?: 0) + + (if (dimensionalPriceGroupId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index 35ae5637..c9714ee8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -773,8 +773,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newFloatingUnitPrice != null -> visitor.visitNewFloatingUnitPrice(newFloatingUnitPrice) newFloatingPackagePrice != null -> @@ -866,7 +866,6 @@ private constructor( ) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1054,6 +1053,145 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewFloatingUnitPrice( + newFloatingUnitPrice: NewFloatingUnitPrice + ) = newFloatingUnitPrice.validity() + + override fun visitNewFloatingPackagePrice( + newFloatingPackagePrice: NewFloatingPackagePrice + ) = newFloatingPackagePrice.validity() + + override fun visitNewFloatingMatrixPrice( + newFloatingMatrixPrice: NewFloatingMatrixPrice + ) = newFloatingMatrixPrice.validity() + + override fun visitNewFloatingMatrixWithAllocationPrice( + newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice + ) = newFloatingMatrixWithAllocationPrice.validity() + + override fun visitNewFloatingTieredPrice( + newFloatingTieredPrice: NewFloatingTieredPrice + ) = newFloatingTieredPrice.validity() + + override fun visitNewFloatingTieredBpsPrice( + newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice + ) = newFloatingTieredBpsPrice.validity() + + override fun visitNewFloatingBpsPrice( + newFloatingBpsPrice: NewFloatingBpsPrice + ) = newFloatingBpsPrice.validity() + + override fun visitNewFloatingBulkBpsPrice( + newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice + ) = newFloatingBulkBpsPrice.validity() + + override fun visitNewFloatingBulkPrice( + newFloatingBulkPrice: NewFloatingBulkPrice + ) = newFloatingBulkPrice.validity() + + override fun visitNewFloatingThresholdTotalAmountPrice( + newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice + ) = newFloatingThresholdTotalAmountPrice.validity() + + override fun visitNewFloatingTieredPackagePrice( + newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice + ) = newFloatingTieredPackagePrice.validity() + + override fun visitNewFloatingGroupedTieredPrice( + newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice + ) = newFloatingGroupedTieredPrice.validity() + + override fun visitNewFloatingMaxGroupTieredPackagePrice( + newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice + ) = newFloatingMaxGroupTieredPackagePrice.validity() + + override fun visitNewFloatingTieredWithMinimumPrice( + newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice + ) = newFloatingTieredWithMinimumPrice.validity() + + override fun visitNewFloatingPackageWithAllocationPrice( + newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice + ) = newFloatingPackageWithAllocationPrice.validity() + + override fun visitNewFloatingTieredPackageWithMinimumPrice( + newFloatingTieredPackageWithMinimumPrice: + NewFloatingTieredPackageWithMinimumPrice + ) = newFloatingTieredPackageWithMinimumPrice.validity() + + override fun visitNewFloatingUnitWithPercentPrice( + newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice + ) = newFloatingUnitWithPercentPrice.validity() + + override fun visitNewFloatingTieredWithProrationPrice( + newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice + ) = newFloatingTieredWithProrationPrice.validity() + + override fun visitNewFloatingUnitWithProrationPrice( + newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice + ) = newFloatingUnitWithProrationPrice.validity() + + override fun visitNewFloatingGroupedAllocationPrice( + newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice + ) = newFloatingGroupedAllocationPrice.validity() + + override fun visitNewFloatingGroupedWithProratedMinimumPrice( + newFloatingGroupedWithProratedMinimumPrice: + NewFloatingGroupedWithProratedMinimumPrice + ) = newFloatingGroupedWithProratedMinimumPrice.validity() + + override fun visitNewFloatingGroupedWithMeteredMinimumPrice( + newFloatingGroupedWithMeteredMinimumPrice: + NewFloatingGroupedWithMeteredMinimumPrice + ) = newFloatingGroupedWithMeteredMinimumPrice.validity() + + override fun visitNewFloatingMatrixWithDisplayNamePrice( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) = newFloatingMatrixWithDisplayNamePrice.validity() + + override fun visitNewFloatingBulkWithProrationPrice( + newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice + ) = newFloatingBulkWithProrationPrice.validity() + + override fun visitNewFloatingGroupedTieredPackagePrice( + newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice + ) = newFloatingGroupedTieredPackagePrice.validity() + + override fun visitNewFloatingScalableMatrixWithUnitPricingPrice( + newFloatingScalableMatrixWithUnitPricingPrice: + NewFloatingScalableMatrixWithUnitPricingPrice + ) = newFloatingScalableMatrixWithUnitPricingPrice.validity() + + override fun visitNewFloatingScalableMatrixWithTieredPricingPrice( + newFloatingScalableMatrixWithTieredPricingPrice: + NewFloatingScalableMatrixWithTieredPricingPrice + ) = newFloatingScalableMatrixWithTieredPricingPrice.validity() + + override fun visitNewFloatingCumulativeGroupedBulkPrice( + newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice + ) = newFloatingCumulativeGroupedBulkPrice.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1408,256 +1546,209 @@ private constructor( when (modelType) { "unit" -> { - return Body( - newFloatingUnitPrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(newFloatingUnitPrice = it, _json = json) + } ?: Body(_json = json) } "package" -> { - return Body( - newFloatingPackagePrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(newFloatingPackagePrice = it, _json = json) } + ?: Body(_json = json) } "matrix" -> { - return Body( - newFloatingMatrixPrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(newFloatingMatrixPrice = it, _json = json) + } ?: Body(_json = json) } "matrix_with_allocation" -> { - return Body( - newFloatingMatrixWithAllocationPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingMatrixWithAllocationPrice = it, _json = json) } + ?: Body(_json = json) } "tiered" -> { - return Body( - newFloatingTieredPrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(newFloatingTieredPrice = it, _json = json) + } ?: Body(_json = json) } "tiered_bps" -> { - return Body( - newFloatingTieredBpsPrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(newFloatingTieredBpsPrice = it, _json = json) } + ?: Body(_json = json) } "bps" -> { - return Body( - newFloatingBpsPrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(newFloatingBpsPrice = it, _json = json) + } ?: Body(_json = json) } "bulk_bps" -> { - return Body( - newFloatingBulkBpsPrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(newFloatingBulkBpsPrice = it, _json = json) } + ?: Body(_json = json) } "bulk" -> { - return Body( - newFloatingBulkPrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(newFloatingBulkPrice = it, _json = json) + } ?: Body(_json = json) } "threshold_total_amount" -> { - return Body( - newFloatingThresholdTotalAmountPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingThresholdTotalAmountPrice = it, _json = json) } + ?: Body(_json = json) } "tiered_package" -> { - return Body( - newFloatingTieredPackagePrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(newFloatingTieredPackagePrice = it, _json = json) } + ?: Body(_json = json) } "grouped_tiered" -> { - return Body( - newFloatingGroupedTieredPrice = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(newFloatingGroupedTieredPrice = it, _json = json) } + ?: Body(_json = json) } "max_group_tiered_package" -> { - return Body( - newFloatingMaxGroupTieredPackagePrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingMaxGroupTieredPackagePrice = it, _json = json) } + ?: Body(_json = json) } "tiered_with_minimum" -> { - return Body( - newFloatingTieredWithMinimumPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingTieredWithMinimumPrice = it, _json = json) } + ?: Body(_json = json) } "package_with_allocation" -> { - return Body( - newFloatingPackageWithAllocationPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingPackageWithAllocationPrice = it, _json = json) } + ?: Body(_json = json) } "tiered_package_with_minimum" -> { - return Body( - newFloatingTieredPackageWithMinimumPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(newFloatingTieredPackageWithMinimumPrice = it, _json = json) + } ?: Body(_json = json) } "unit_with_percent" -> { - return Body( - newFloatingUnitWithPercentPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingUnitWithPercentPrice = it, _json = json) } + ?: Body(_json = json) } "tiered_with_proration" -> { - return Body( - newFloatingTieredWithProrationPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingTieredWithProrationPrice = it, _json = json) } + ?: Body(_json = json) } "unit_with_proration" -> { - return Body( - newFloatingUnitWithProrationPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingUnitWithProrationPrice = it, _json = json) } + ?: Body(_json = json) } "grouped_allocation" -> { - return Body( - newFloatingGroupedAllocationPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingGroupedAllocationPrice = it, _json = json) } + ?: Body(_json = json) } "grouped_with_prorated_minimum" -> { - return Body( - newFloatingGroupedWithProratedMinimumPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(newFloatingGroupedWithProratedMinimumPrice = it, _json = json) + } ?: Body(_json = json) } "grouped_with_metered_minimum" -> { - return Body( - newFloatingGroupedWithMeteredMinimumPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body(newFloatingGroupedWithMeteredMinimumPrice = it, _json = json) + } ?: Body(_json = json) } "matrix_with_display_name" -> { - return Body( - newFloatingMatrixWithDisplayNamePrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingMatrixWithDisplayNamePrice = it, _json = json) } + ?: Body(_json = json) } "bulk_with_proration" -> { - return Body( - newFloatingBulkWithProrationPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingBulkWithProrationPrice = it, _json = json) } + ?: Body(_json = json) } "grouped_tiered_package" -> { - return Body( - newFloatingGroupedTieredPackagePrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingGroupedTieredPackagePrice = it, _json = json) } + ?: Body(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return Body( - newFloatingScalableMatrixWithUnitPricingPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body( + newFloatingScalableMatrixWithUnitPricingPrice = it, + _json = json, + ) + } ?: Body(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return Body( - newFloatingScalableMatrixWithTieredPricingPrice = - deserialize( - node, - jacksonTypeRef< - NewFloatingScalableMatrixWithTieredPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Body( + newFloatingScalableMatrixWithTieredPricingPrice = it, + _json = json, + ) + } ?: Body(_json = json) } "cumulative_grouped_bulk" -> { - return Body( - newFloatingCumulativeGroupedBulkPrice = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(newFloatingCumulativeGroupedBulkPrice = it, _json = json) } + ?: Body(_json = json) } } @@ -2548,10 +2639,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() unitConfig().validate() billableMetricId() @@ -2566,6 +2657,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2682,6 +2805,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2780,6 +2930,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2928,6 +3105,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3125,10 +3319,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -3225,6 +3438,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3436,10 +3677,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -3536,6 +3796,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3641,6 +3929,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4493,10 +4801,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() packageConfig().validate() billableMetricId() @@ -4511,6 +4819,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4627,6 +4967,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4725,6 +5092,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4921,6 +5315,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5118,10 +5531,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -5218,6 +5650,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5429,10 +5889,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -5529,6 +6008,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5634,6 +6141,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6485,11 +7012,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() matrixConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -6503,6 +7030,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6619,6 +7178,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6883,6 +7469,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -7085,6 +7693,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7206,6 +7834,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7398,10 +8053,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -7498,6 +8172,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7709,10 +8411,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -7809,6 +8530,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7914,6 +8663,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8775,11 +9544,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() matrixWithAllocationConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -8793,6 +9562,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8909,6 +9710,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9221,6 +10049,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -9423,6 +10274,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9544,6 +10415,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9736,10 +10634,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -9836,6 +10753,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10047,10 +10992,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -10147,6 +11111,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10252,6 +11244,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11103,10 +12115,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredConfig().validate() billableMetricId() @@ -11121,6 +12133,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -11237,6 +12281,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11335,6 +12406,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11493,6 +12591,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val firstUnit: JsonField, @@ -11725,6 +12841,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11940,10 +13076,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -12040,6 +13195,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12251,10 +13434,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -12351,6 +13553,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12456,6 +13686,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13309,10 +14559,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredBpsConfig().validate() billableMetricId() @@ -13327,6 +14577,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -13443,6 +14725,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13541,6 +14850,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13703,6 +15039,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -13977,6 +15331,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14192,10 +15567,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -14292,6 +15686,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14503,10 +15925,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -14603,6 +16044,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14708,6 +16177,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15557,10 +17046,10 @@ private constructor( } bpsConfig().validate() - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -15574,6 +17063,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BpsConfig private constructor( private val bps: JsonField, @@ -15751,6 +17272,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15885,6 +17425,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15983,6 +17550,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16175,10 +17769,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -16275,6 +17888,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16486,10 +18127,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -16586,6 +18246,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16691,6 +18379,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17544,10 +19252,10 @@ private constructor( } bulkBpsConfig().validate() - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -17561,6 +19269,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkBpsConfig private constructor( private val tiers: JsonField>, @@ -17710,6 +19450,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -17940,6 +19698,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18092,6 +19870,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18190,6 +19995,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18382,10 +20214,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -18482,6 +20333,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18693,10 +20572,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -18793,6 +20691,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18898,6 +20824,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19747,10 +21693,10 @@ private constructor( } bulkConfig().validate() - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -19764,6 +21710,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkConfig private constructor( private val tiers: JsonField>, @@ -19909,6 +21887,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val unitAmount: JsonField, @@ -20102,6 +22098,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (maximumUnits.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20254,6 +22269,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20352,6 +22394,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20544,10 +22613,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -20644,6 +22732,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20855,10 +22971,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -20955,6 +23090,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21060,6 +23223,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21921,10 +24104,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -21939,6 +24122,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -22055,6 +24270,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22153,6 +24395,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22241,6 +24510,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22438,10 +24727,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -22538,6 +24846,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22749,10 +25085,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -22849,6 +25204,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22954,6 +25337,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23810,10 +26213,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredPackageConfig().validate() billableMetricId() @@ -23828,6 +26231,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23944,6 +26379,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24042,6 +26504,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24129,6 +26618,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24326,10 +26835,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24426,6 +26954,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24637,10 +27193,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24737,6 +27312,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24842,6 +27445,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25698,11 +28321,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedTieredConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -25716,6 +28339,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -25832,6 +28487,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25919,6 +28601,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26022,6 +28724,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26214,10 +28943,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26314,6 +29062,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26525,10 +29301,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26625,6 +29420,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26730,6 +29553,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27591,11 +30434,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() maxGroupTieredPackageConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -27609,6 +30452,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -27725,6 +30600,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27813,6 +30715,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27916,6 +30838,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28108,10 +31057,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28208,6 +31176,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28419,10 +31415,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28519,6 +31534,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28624,6 +31667,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29482,10 +32545,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredWithMinimumConfig().validate() billableMetricId() @@ -29500,6 +32563,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -29616,6 +32711,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29714,6 +32836,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29801,6 +32950,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29998,10 +33167,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30098,6 +33286,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30309,10 +33525,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30409,6 +33644,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30514,6 +33777,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31375,10 +34658,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() packageWithAllocationConfig().validate() billableMetricId() @@ -31393,6 +34676,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -31509,6 +34824,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31607,6 +34949,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31695,6 +35064,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31892,10 +35281,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -31992,6 +35400,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32203,10 +35639,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32303,6 +35758,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32408,6 +35891,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33274,10 +36777,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredPackageWithMinimumConfig().validate() billableMetricId() @@ -33292,6 +36795,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -33408,6 +36943,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33506,6 +37068,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33595,6 +37184,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33792,10 +37401,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -33892,6 +37520,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34103,10 +37759,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34203,6 +37878,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34308,6 +38011,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35165,10 +38888,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() unitWithPercentConfig().validate() billableMetricId() @@ -35183,6 +38906,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -35299,6 +39054,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35397,6 +39179,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35484,6 +39293,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35681,10 +39510,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -35781,6 +39629,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35992,10 +39868,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -36092,6 +39987,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36197,6 +40120,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37056,10 +40999,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredWithProrationConfig().validate() billableMetricId() @@ -37074,6 +41017,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -37190,6 +41165,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37288,6 +41290,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37376,6 +41405,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37573,10 +41622,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -37673,6 +41741,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37884,10 +41980,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -37984,6 +42099,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38089,6 +42232,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38947,10 +43110,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() unitWithProrationConfig().validate() billableMetricId() @@ -38965,6 +43128,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -39081,6 +43276,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39179,6 +43401,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39266,6 +43515,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39463,10 +43732,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -39563,6 +43851,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39774,10 +44090,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -39874,6 +44209,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39979,6 +44342,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40837,11 +45220,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedAllocationConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -40855,6 +45238,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -40971,6 +45386,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41058,6 +45500,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41161,6 +45623,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41353,10 +45842,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -41453,6 +45961,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41664,10 +46200,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -41764,6 +46319,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41869,6 +46452,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42741,11 +47344,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedWithProratedMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -42759,6 +47362,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -42875,6 +47510,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42964,6 +47626,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43068,6 +47750,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43260,10 +47969,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -43360,6 +48088,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43571,10 +48327,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -43671,6 +48446,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43776,6 +48579,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44645,11 +49468,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedWithMeteredMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -44663,6 +49486,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -44779,6 +49634,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44868,6 +49750,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44971,6 +49873,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45163,10 +50092,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -45263,6 +50211,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45474,10 +50450,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -45574,6 +50569,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45679,6 +50702,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46540,11 +51583,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() matrixWithDisplayNameConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -46558,6 +51601,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -46674,6 +51749,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46762,6 +51864,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46865,6 +51987,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47057,10 +52206,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -47157,6 +52325,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47368,10 +52564,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -47468,6 +52683,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47573,6 +52816,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48432,10 +53695,10 @@ private constructor( } bulkWithProrationConfig().validate() - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -48449,6 +53712,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkWithProrationConfig @JsonCreator private constructor( @@ -48523,6 +53818,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48657,6 +53972,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48755,6 +54097,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48947,10 +54316,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -49047,6 +54435,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49258,10 +54674,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -49358,6 +54793,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49463,6 +54926,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50324,11 +55807,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedTieredPackageConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -50342,6 +55825,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -50458,6 +55973,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50546,6 +56088,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50649,6 +56211,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50841,10 +56430,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -50941,6 +56549,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51124,239 +56760,306 @@ private constructor( } /** - * Returns an immutable instance of [InvoicingCycleConfiguration]. + * Returns an immutable instance of [InvoicingCycleConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoicingCycleConfiguration = + InvoicingCycleConfiguration( + checkRequired("duration", duration), + checkRequired("durationUnit", durationUnit), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (validated) { + return@apply + } + + duration() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + + /** The unit of billing period duration. */ + class DurationUnit + @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 { + + @JvmField val DAY = of("day") + + @JvmField val MONTH = of("month") + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + /** An enum containing [DurationUnit]'s known values. */ + enum class Known { + DAY, + MONTH, + } + + /** + * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DurationUnit] 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 { + DAY, + MONTH, + /** + * An enum member indicating that [DurationUnit] 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) { + DAY -> Value.DAY + MONTH -> Value.MONTH + 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) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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. - * - * The following fields are required: - * ```java - * .duration() - * .durationUnit() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): InvoicingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } - /** The unit of billing period duration. */ - class DurationUnit - @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 { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] 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 { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] 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) { - DAY -> Value.DAY - MONTH -> Value.MONTH - 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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $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().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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 + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - validated = true - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52238,10 +57941,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -52256,6 +57959,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -52372,6 +58107,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52471,6 +58233,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52560,6 +58349,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52757,10 +58566,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -52857,6 +58685,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53068,10 +58924,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -53168,6 +59043,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53273,6 +59176,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54159,10 +60082,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -54177,6 +60100,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -54293,6 +60248,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54395,6 +60377,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54485,6 +60494,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54682,10 +60711,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -54782,6 +60830,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54993,10 +61069,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -55093,6 +61188,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55198,6 +61321,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56059,11 +62202,11 @@ private constructor( return@apply } - cadence() + cadence().validate() cumulativeGroupedBulkConfig().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -56077,6 +62220,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -56193,6 +62368,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56281,6 +62483,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56384,6 +62606,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56576,10 +62825,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -56676,6 +62944,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56887,10 +63183,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -56987,6 +63302,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57092,6 +63435,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt index c6b96407..9eb5c4be 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt @@ -819,6 +819,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt index 88407109..aec7f52c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt @@ -16,6 +16,7 @@ import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull class PriceEvaluateResponse private constructor( @@ -154,6 +155,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt index 34240c4c..72b3f71c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt @@ -382,6 +382,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -471,6 +488,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt index 6841dfe9..648f37e8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.PriceService import java.util.Collections import java.util.Objects @@ -129,6 +130,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt index 4627c7e7..86309614 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.PriceServiceAsync import java.util.Collections import java.util.Objects @@ -131,6 +132,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt index 732852c4..9a9fb0a0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt @@ -377,6 +377,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -466,6 +483,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt index 737fc7f4..aafafb4f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt @@ -1391,11 +1391,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1736,6 +1777,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1790,8 +1853,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1802,7 +1865,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1847,6 +1909,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1943,48 +2047,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2444,7 +2544,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2453,6 +2553,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2542,6 +2666,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3001,7 +3153,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3010,6 +3162,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3099,6 +3275,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3561,7 +3765,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3570,6 +3774,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3659,6 +3887,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4156,7 +4412,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4166,6 +4422,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4255,6 +4536,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4713,7 +5022,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4722,6 +5031,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4811,6 +5144,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5090,6 +5451,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5138,14 +5519,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5172,6 +5552,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5239,23 +5648,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5670,12 +6075,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5763,6 +6191,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6187,13 +6642,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6281,6 +6759,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6704,13 +7209,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6798,6 +7326,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7063,6 +7618,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7424,6 +8000,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7513,6 +8111,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7873,6 +8489,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8665,6 +9303,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8871,6 +9537,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9108,6 +9794,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9216,6 +9922,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9355,6 +10088,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt index 7345b6e3..71da264a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt @@ -638,12 +638,32 @@ private constructor( return@apply } - cancelOption() + cancelOption().validate() allowInvoiceCreditOrVoid() cancellationDate() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancelOption.asKnown().getOrNull()?.validity() ?: 0) + + (if (allowInvoiceCreditOrVoid.asKnown().isPresent) 1 else 0) + + (if (cancellationDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -756,6 +776,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): CancelOption = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt index 279e30f5..58fb8937 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt @@ -1379,11 +1379,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1724,6 +1765,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1778,8 +1841,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1790,7 +1853,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1835,6 +1897,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1931,48 +2035,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2432,7 +2532,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2441,6 +2541,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2530,6 +2654,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2989,7 +3141,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -2998,6 +3150,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3087,6 +3263,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3549,7 +3753,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3558,6 +3762,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3647,6 +3875,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4144,7 +4400,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4154,6 +4410,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4243,6 +4524,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4701,7 +5010,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4710,6 +5019,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4799,6 +5132,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5078,6 +5439,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5126,14 +5507,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5160,6 +5540,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5227,23 +5636,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5658,12 +6063,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5751,6 +6179,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6175,13 +6630,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6269,6 +6747,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6692,13 +7197,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6786,6 +7314,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7051,6 +7606,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7412,6 +7988,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7501,6 +8099,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7861,6 +8477,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8653,6 +9291,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8859,6 +9525,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9096,6 +9782,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9204,6 +9910,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9343,6 +10076,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 612a7721..bfe588aa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -3483,7 +3483,7 @@ private constructor( defaultInvoiceMemo() endDate() externalCustomerId() - externalMarketplace() + externalMarketplace().ifPresent { it.validate() } externalMarketplaceReportingId() externalPlanId() filter() @@ -3505,6 +3505,54 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addAdjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (addPrices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (alignBillingWithSubscriptionStartDate.asKnown().isPresent) 1 else 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (awsRegion.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (couponRedemptionCode.asKnown().isPresent) 1 else 0) + + (if (creditsOverageRate.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + + (externalMarketplace.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalMarketplaceReportingId.asKnown().isPresent) 1 else 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (initialPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (perCreditOverageAmount.asKnown().isPresent) 1 else 0) + + (if (planId.asKnown().isPresent) 1 else 0) + + (if (planVersionNumber.asKnown().isPresent) 1 else 0) + + (priceOverrides.asKnown().getOrNull()?.size ?: 0) + + (removeAdjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (removePrices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (replaceAdjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (replacePrices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (trialDurationDays.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3829,6 +3877,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + /** The definition of a new adjustment to create and add to the subscription. */ @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) @@ -3880,8 +3949,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newPercentageDiscount != null -> visitor.visitNewPercentageDiscount(newPercentageDiscount) newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) @@ -3890,7 +3959,6 @@ private constructor( newMaximum != null -> visitor.visitNewMaximum(newMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -3927,6 +3995,42 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewPercentageDiscount( + newPercentageDiscount: NewPercentageDiscount + ) = newPercentageDiscount.validity() + + override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = + newUsageDiscount.validity() + + override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = + newAmountDiscount.validity() + + override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + + override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4010,37 +4114,29 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return Adjustment( - newPercentageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(newPercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "usage_discount" -> { - return Adjustment( - newUsageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newUsageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - newAmountDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newAmountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - newMinimum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMinimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - newMaximum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMaximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -4352,13 +4448,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() percentageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4448,6 +4565,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4758,13 +4903,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() usageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4854,6 +5020,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5165,13 +5359,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5261,6 +5476,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5609,7 +5852,7 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() itemId() minimumAmount() @@ -5617,6 +5860,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5706,6 +5971,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6015,13 +6308,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() maximumAmount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6111,6 +6425,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6973,6 +7315,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + /** The definition of a new allocation price to create and add to the subscription. */ class AllocationPrice private constructor( @@ -7230,12 +7599,33 @@ private constructor( } amount() - cadence() + cadence().validate() currency() expiresAtEndOfCadence() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expiresAtEndOfCadence.asKnown().isPresent) 1 else 0) + /** The cadence at which to allocate the amount to the customer. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -7352,6 +7742,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7680,13 +8097,34 @@ private constructor( return@apply } - discountType() + discountType().validate() amountDiscount() percentageDiscount() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -7786,6 +8224,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8135,8 +8600,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newSubscriptionUnit != null -> visitor.visitNewSubscriptionUnit(newSubscriptionUnit) newSubscriptionPackage != null -> @@ -8219,7 +8684,6 @@ private constructor( ) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -8394,6 +8858,138 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewSubscriptionUnit( + newSubscriptionUnit: NewSubscriptionUnitPrice + ) = newSubscriptionUnit.validity() + + override fun visitNewSubscriptionPackage( + newSubscriptionPackage: NewSubscriptionPackagePrice + ) = newSubscriptionPackage.validity() + + override fun visitNewSubscriptionMatrix( + newSubscriptionMatrix: NewSubscriptionMatrixPrice + ) = newSubscriptionMatrix.validity() + + override fun visitNewSubscriptionTiered( + newSubscriptionTiered: NewSubscriptionTieredPrice + ) = newSubscriptionTiered.validity() + + override fun visitNewSubscriptionTieredBps( + newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice + ) = newSubscriptionTieredBps.validity() + + override fun visitNewSubscriptionBps( + newSubscriptionBps: NewSubscriptionBpsPrice + ) = newSubscriptionBps.validity() + + override fun visitNewSubscriptionBulkBps( + newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice + ) = newSubscriptionBulkBps.validity() + + override fun visitNewSubscriptionBulk( + newSubscriptionBulk: NewSubscriptionBulkPrice + ) = newSubscriptionBulk.validity() + + override fun visitNewSubscriptionThresholdTotalAmount( + newSubscriptionThresholdTotalAmount: + NewSubscriptionThresholdTotalAmountPrice + ) = newSubscriptionThresholdTotalAmount.validity() + + override fun visitNewSubscriptionTieredPackage( + newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice + ) = newSubscriptionTieredPackage.validity() + + override fun visitNewSubscriptionTieredWithMinimum( + newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = newSubscriptionTieredWithMinimum.validity() + + override fun visitNewSubscriptionUnitWithPercent( + newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = newSubscriptionUnitWithPercent.validity() + + override fun visitNewSubscriptionPackageWithAllocation( + newSubscriptionPackageWithAllocation: + NewSubscriptionPackageWithAllocationPrice + ) = newSubscriptionPackageWithAllocation.validity() + + override fun visitNewSubscriptionTierWithProration( + newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice + ) = newSubscriptionTierWithProration.validity() + + override fun visitNewSubscriptionUnitWithProration( + newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice + ) = newSubscriptionUnitWithProration.validity() + + override fun visitNewSubscriptionGroupedAllocation( + newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = newSubscriptionGroupedAllocation.validity() + + override fun visitNewSubscriptionGroupedWithProratedMinimum( + newSubscriptionGroupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = newSubscriptionGroupedWithProratedMinimum.validity() + + override fun visitNewSubscriptionBulkWithProration( + newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = newSubscriptionBulkWithProration.validity() + + override fun visitNewSubscriptionScalableMatrixWithUnitPricing( + newSubscriptionScalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = newSubscriptionScalableMatrixWithUnitPricing.validity() + + override fun visitNewSubscriptionScalableMatrixWithTieredPricing( + newSubscriptionScalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = newSubscriptionScalableMatrixWithTieredPricing.validity() + + override fun visitNewSubscriptionCumulativeGroupedBulk( + newSubscriptionCumulativeGroupedBulk: + NewSubscriptionCumulativeGroupedBulkPrice + ) = newSubscriptionCumulativeGroupedBulk.validity() + + override fun visitNewSubscriptionMaxGroupTieredPackage( + newSubscriptionMaxGroupTieredPackage: + NewSubscriptionMaxGroupTieredPackagePrice + ) = newSubscriptionMaxGroupTieredPackage.validity() + + override fun visitNewSubscriptionGroupedWithMeteredMinimum( + newSubscriptionGroupedWithMeteredMinimum: + NewSubscriptionGroupedWithMeteredMinimumPrice + ) = newSubscriptionGroupedWithMeteredMinimum.validity() + + override fun visitNewSubscriptionMatrixWithDisplayName( + newSubscriptionMatrixWithDisplayName: + NewSubscriptionMatrixWithDisplayNamePrice + ) = newSubscriptionMatrixWithDisplayName.validity() + + override fun visitNewSubscriptionGroupedTieredPackage( + newSubscriptionGroupedTieredPackage: + NewSubscriptionGroupedTieredPackagePrice + ) = newSubscriptionGroupedTieredPackage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8733,247 +9329,221 @@ private constructor( when (modelType) { "unit" -> { - return Price( - newSubscriptionUnit = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionUnit = it, _json = json) } + ?: Price(_json = json) } "package" -> { - return Price( - newSubscriptionPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionPackage = it, _json = json) } + ?: Price(_json = json) } "matrix" -> { - return Price( - newSubscriptionMatrix = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionMatrix = it, _json = json) } + ?: Price(_json = json) } "tiered" -> { - return Price( - newSubscriptionTiered = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTiered = it, _json = json) } + ?: Price(_json = json) } "tiered_bps" -> { - return Price( - newSubscriptionTieredBps = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredBps = it, _json = json) } + ?: Price(_json = json) } "bps" -> { - return Price( - newSubscriptionBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionBps = it, _json = json) } + ?: Price(_json = json) } "bulk_bps" -> { - return Price( - newSubscriptionBulkBps = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionBulkBps = it, _json = json) } + ?: Price(_json = json) } "bulk" -> { - return Price( - newSubscriptionBulk = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionBulk = it, _json = json) } + ?: Price(_json = json) } "threshold_total_amount" -> { - return Price( - newSubscriptionThresholdTotalAmount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionThresholdTotalAmount = it, _json = json) + } ?: Price(_json = json) } "tiered_package" -> { - return Price( - newSubscriptionTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredPackage = it, _json = json) } + ?: Price(_json = json) } "tiered_with_minimum" -> { - return Price( - newSubscriptionTieredWithMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } "unit_with_percent" -> { - return Price( - newSubscriptionUnitWithPercent = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionUnitWithPercent = it, _json = json) } + ?: Price(_json = json) } "package_with_allocation" -> { - return Price( - newSubscriptionPackageWithAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionPackageWithAllocation = it, _json = json) + } ?: Price(_json = json) } "tiered_with_proration" -> { - return Price( - newSubscriptionTierWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTierWithProration = it, _json = json) } + ?: Price(_json = json) } "unit_with_proration" -> { - return Price( - newSubscriptionUnitWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionUnitWithProration = it, _json = json) } + ?: Price(_json = json) } "grouped_allocation" -> { - return Price( - newSubscriptionGroupedAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionGroupedAllocation = it, _json = json) } + ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return Price( - newSubscriptionGroupedWithProratedMinimum = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionGroupedWithProratedMinimumPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newSubscriptionGroupedWithProratedMinimum = it, + _json = json, + ) + } ?: Price(_json = json) } "bulk_with_proration" -> { - return Price( - newSubscriptionBulkWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionBulkWithProration = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return Price( - newSubscriptionScalableMatrixWithUnitPricing = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { + Price( + newSubscriptionScalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return Price( - newSubscriptionScalableMatrixWithTieredPricing = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { + Price( + newSubscriptionScalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return Price( - newSubscriptionCumulativeGroupedBulk = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionCumulativeGroupedBulk = it, _json = json) + } ?: Price(_json = json) } "max_group_tiered_package" -> { - return Price( - newSubscriptionMaxGroupTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionMaxGroupTieredPackage = it, _json = json) + } ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return Price( - newSubscriptionGroupedWithMeteredMinimum = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionGroupedWithMeteredMinimumPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newSubscriptionGroupedWithMeteredMinimum = it, + _json = json, + ) + } ?: Price(_json = json) } "matrix_with_display_name" -> { - return Price( - newSubscriptionMatrixWithDisplayName = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionMatrixWithDisplayName = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered_package" -> { - return Price( - newSubscriptionGroupedTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionGroupedTieredPackage = it, _json = json) + } ?: Price(_json = json) } } @@ -9944,9 +10514,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitConfig().validate() billableMetricId() @@ -9963,6 +10533,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -10081,6 +10684,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10182,6 +10813,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10331,6 +10990,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10530,10 +11206,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -10631,6 +11326,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10844,10 +11567,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -10945,6 +11687,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11051,6 +11821,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11983,9 +12773,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageConfig().validate() billableMetricId() @@ -12002,6 +12792,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -12120,6 +12943,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12221,6 +13072,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12419,6 +13298,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12618,10 +13516,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -12719,6 +13636,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12932,10 +13877,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -13033,6 +13997,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13139,6 +14131,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14071,10 +15083,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -14090,6 +15102,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -14208,6 +15253,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14480,6 +15553,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -14687,6 +15783,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14811,6 +15927,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15005,10 +16149,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -15106,6 +16269,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15319,10 +16510,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -15420,6 +16630,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15526,6 +16764,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16458,9 +17716,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredConfig().validate() billableMetricId() @@ -16477,6 +17735,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -16595,6 +17886,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16696,6 +18015,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16860,6 +18207,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val firstUnit: JsonField, @@ -17099,6 +18464,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17316,10 +18701,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -17417,6 +18821,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17630,10 +19062,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -17731,6 +19182,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17837,6 +19316,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18771,9 +20270,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredBpsConfig().validate() billableMetricId() @@ -18790,6 +20289,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -18908,6 +20440,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19009,6 +20569,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19177,6 +20765,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -19452,6 +21058,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19669,10 +21296,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -19770,6 +21416,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19983,10 +21657,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -20084,6 +21777,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20190,6 +21911,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21121,9 +22862,9 @@ private constructor( } bpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -21139,6 +22880,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BpsConfig private constructor( private val bps: JsonField, @@ -21320,6 +23094,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21456,6 +23249,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21557,6 +23378,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21751,10 +23600,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -21852,6 +23720,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22065,10 +23961,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -22166,6 +24081,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22272,6 +24215,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23205,9 +25168,9 @@ private constructor( } bulkBpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -23223,6 +25186,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkBpsConfig private constructor( private val tiers: JsonField>, @@ -23377,6 +25373,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -23608,6 +25622,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23762,6 +25796,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23863,6 +25925,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24057,10 +26147,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24158,6 +26267,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24371,10 +26508,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24472,6 +26628,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24578,6 +26762,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25509,9 +27713,9 @@ private constructor( } bulkConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -25527,6 +27731,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkConfig private constructor( private val tiers: JsonField>, @@ -25676,6 +27913,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val unitAmount: JsonField, @@ -25871,6 +28126,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (maximumUnits.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26025,6 +28299,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26126,6 +28428,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26320,10 +28650,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26421,6 +28770,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26634,10 +29011,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26735,6 +29131,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26841,6 +29265,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27785,9 +30229,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -27804,6 +30248,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -27922,6 +30399,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28023,6 +30528,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28112,6 +30645,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28311,10 +30864,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28412,6 +30984,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28625,10 +31225,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28726,6 +31345,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28832,6 +31479,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29767,9 +32434,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredPackageConfig().validate() billableMetricId() @@ -29786,6 +32453,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -29904,6 +32604,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30005,6 +32733,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30093,6 +32849,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30292,10 +33068,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30393,6 +33188,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30606,10 +33429,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30707,6 +33549,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30813,6 +33683,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31752,9 +34642,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithMinimumConfig().validate() billableMetricId() @@ -31771,6 +34661,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -31889,6 +34812,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31990,6 +34941,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32079,6 +35058,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32278,10 +35277,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32379,6 +35397,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32592,10 +35638,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32693,6 +35758,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32799,6 +35892,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33735,9 +36848,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithPercentConfig().validate() billableMetricId() @@ -33754,6 +36867,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -33872,6 +37018,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33973,6 +37147,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34061,6 +37263,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34260,10 +37482,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34361,6 +37602,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34574,10 +37843,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34675,6 +37963,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34781,6 +38097,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35730,9 +39066,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageWithAllocationConfig().validate() billableMetricId() @@ -35749,6 +39085,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -35867,6 +39236,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35968,6 +39365,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36058,6 +39483,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36257,10 +39702,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -36358,6 +39822,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36571,10 +40063,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -36672,6 +40183,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36778,6 +40317,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37720,9 +41279,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithProrationConfig().validate() billableMetricId() @@ -37739,6 +41298,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -37857,6 +41449,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37958,6 +41578,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38047,6 +41695,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38246,10 +41914,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -38347,6 +42034,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38560,10 +42275,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -38661,6 +42395,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38767,6 +42529,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39706,9 +43488,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithProrationConfig().validate() billableMetricId() @@ -39725,6 +43507,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -39843,6 +43658,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39944,6 +43787,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40033,6 +43904,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40232,10 +44123,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -40333,6 +44243,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40546,10 +44484,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -40647,6 +44604,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40753,6 +44738,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41692,10 +45697,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedAllocationConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -41711,6 +45716,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -41829,6 +45867,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41918,6 +45984,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42024,6 +46110,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42218,10 +46332,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -42319,6 +46452,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42532,10 +46693,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -42633,6 +46813,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42739,6 +46947,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43703,10 +47931,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -43722,6 +47950,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -43840,6 +48101,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43930,6 +48219,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44037,6 +48346,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44231,10 +48568,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -44332,6 +48688,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44545,10 +48929,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -44646,6 +49049,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44752,6 +49183,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45692,9 +50143,9 @@ private constructor( } bulkWithProrationConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -45710,6 +50161,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkWithProrationConfig @JsonCreator private constructor( @@ -45786,6 +50270,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45922,6 +50426,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46023,6 +50555,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46217,10 +50777,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -46318,6 +50897,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46531,10 +51138,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -46632,6 +51258,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46738,6 +51392,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47707,9 +52381,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -47726,6 +52400,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -47844,6 +52552,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47949,6 +52685,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48040,6 +52804,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48239,10 +53023,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -48340,6 +53143,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48553,10 +53384,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -48654,6 +53504,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48760,6 +53638,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49730,9 +54628,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -49749,6 +54647,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -49867,6 +54799,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49972,6 +54932,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50066,6 +55054,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50265,10 +55273,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -50366,6 +55393,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50579,10 +55634,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -50680,6 +55754,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50786,6 +55888,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51735,10 +56857,10 @@ private constructor( return@apply } - cadence() + cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -51754,6 +56876,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -51872,6 +57027,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51962,6 +57145,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52068,6 +57271,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52262,10 +57493,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -52363,6 +57613,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52576,10 +57854,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -52677,6 +57974,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52783,6 +58108,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53732,10 +59077,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -53751,6 +59096,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -53869,6 +59247,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53959,6 +59365,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54065,6 +59491,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54259,10 +59713,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -54360,6 +59833,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54573,10 +60074,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -54674,6 +60194,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54780,6 +60328,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55743,10 +61311,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -55762,6 +61330,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -55880,6 +61481,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55970,6 +61599,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56077,6 +61726,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56271,10 +61948,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -56372,6 +62068,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56585,10 +62309,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -56686,6 +62429,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56792,6 +62563,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57741,10 +63532,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -57760,6 +63551,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -57878,6 +63702,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57968,6 +63820,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58074,6 +63946,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58268,10 +64168,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -58369,6 +64288,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58582,10 +64529,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -58683,6 +64649,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58789,6 +64783,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59733,10 +65747,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -59752,6 +65766,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -59870,6 +65917,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59959,6 +66034,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60065,6 +66160,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60259,10 +66382,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -60360,6 +66502,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60573,10 +66743,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -60674,6 +66863,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60780,6 +66997,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61063,6 +67300,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61177,6 +67434,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ExternalMarketplace = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61261,6 +67545,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61409,6 +67711,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61582,6 +67901,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61803,6 +68141,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + /** The definition of a new adjustment to create and add to the subscription. */ @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) @@ -61854,8 +68211,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newPercentageDiscount != null -> visitor.visitNewPercentageDiscount(newPercentageDiscount) newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) @@ -61864,7 +68221,6 @@ private constructor( newMaximum != null -> visitor.visitNewMaximum(newMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -61901,6 +68257,42 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewPercentageDiscount( + newPercentageDiscount: NewPercentageDiscount + ) = newPercentageDiscount.validity() + + override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = + newUsageDiscount.validity() + + override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = + newAmountDiscount.validity() + + override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + + override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61984,37 +68376,29 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return Adjustment( - newPercentageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(newPercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "usage_discount" -> { - return Adjustment( - newUsageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newUsageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - newAmountDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newAmountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - newMinimum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMinimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - newMaximum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMaximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -62326,13 +68710,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() percentageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -62422,6 +68827,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62732,13 +69165,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() usageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -62828,6 +69282,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63139,13 +69621,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63235,6 +69738,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63583,7 +70114,7 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() itemId() minimumAmount() @@ -63591,6 +70122,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63680,6 +70233,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63989,13 +70570,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() maximumAmount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -64085,6 +70687,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64913,6 +71543,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + /** The definition of a new allocation price to create and add to the subscription. */ class AllocationPrice private constructor( @@ -65170,12 +71826,33 @@ private constructor( } amount() - cadence() + cadence().validate() currency() expiresAtEndOfCadence() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expiresAtEndOfCadence.asKnown().isPresent) 1 else 0) + /** The cadence at which to allocate the amount to the customer. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -65292,6 +71969,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -65620,13 +72324,34 @@ private constructor( return@apply } - discountType() + discountType().validate() amountDiscount() percentageDiscount() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -65726,6 +72451,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66075,8 +72827,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newSubscriptionUnit != null -> visitor.visitNewSubscriptionUnit(newSubscriptionUnit) newSubscriptionPackage != null -> @@ -66159,7 +72911,6 @@ private constructor( ) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -66334,6 +73085,138 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewSubscriptionUnit( + newSubscriptionUnit: NewSubscriptionUnitPrice + ) = newSubscriptionUnit.validity() + + override fun visitNewSubscriptionPackage( + newSubscriptionPackage: NewSubscriptionPackagePrice + ) = newSubscriptionPackage.validity() + + override fun visitNewSubscriptionMatrix( + newSubscriptionMatrix: NewSubscriptionMatrixPrice + ) = newSubscriptionMatrix.validity() + + override fun visitNewSubscriptionTiered( + newSubscriptionTiered: NewSubscriptionTieredPrice + ) = newSubscriptionTiered.validity() + + override fun visitNewSubscriptionTieredBps( + newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice + ) = newSubscriptionTieredBps.validity() + + override fun visitNewSubscriptionBps( + newSubscriptionBps: NewSubscriptionBpsPrice + ) = newSubscriptionBps.validity() + + override fun visitNewSubscriptionBulkBps( + newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice + ) = newSubscriptionBulkBps.validity() + + override fun visitNewSubscriptionBulk( + newSubscriptionBulk: NewSubscriptionBulkPrice + ) = newSubscriptionBulk.validity() + + override fun visitNewSubscriptionThresholdTotalAmount( + newSubscriptionThresholdTotalAmount: + NewSubscriptionThresholdTotalAmountPrice + ) = newSubscriptionThresholdTotalAmount.validity() + + override fun visitNewSubscriptionTieredPackage( + newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice + ) = newSubscriptionTieredPackage.validity() + + override fun visitNewSubscriptionTieredWithMinimum( + newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = newSubscriptionTieredWithMinimum.validity() + + override fun visitNewSubscriptionUnitWithPercent( + newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = newSubscriptionUnitWithPercent.validity() + + override fun visitNewSubscriptionPackageWithAllocation( + newSubscriptionPackageWithAllocation: + NewSubscriptionPackageWithAllocationPrice + ) = newSubscriptionPackageWithAllocation.validity() + + override fun visitNewSubscriptionTierWithProration( + newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice + ) = newSubscriptionTierWithProration.validity() + + override fun visitNewSubscriptionUnitWithProration( + newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice + ) = newSubscriptionUnitWithProration.validity() + + override fun visitNewSubscriptionGroupedAllocation( + newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = newSubscriptionGroupedAllocation.validity() + + override fun visitNewSubscriptionGroupedWithProratedMinimum( + newSubscriptionGroupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = newSubscriptionGroupedWithProratedMinimum.validity() + + override fun visitNewSubscriptionBulkWithProration( + newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = newSubscriptionBulkWithProration.validity() + + override fun visitNewSubscriptionScalableMatrixWithUnitPricing( + newSubscriptionScalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = newSubscriptionScalableMatrixWithUnitPricing.validity() + + override fun visitNewSubscriptionScalableMatrixWithTieredPricing( + newSubscriptionScalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = newSubscriptionScalableMatrixWithTieredPricing.validity() + + override fun visitNewSubscriptionCumulativeGroupedBulk( + newSubscriptionCumulativeGroupedBulk: + NewSubscriptionCumulativeGroupedBulkPrice + ) = newSubscriptionCumulativeGroupedBulk.validity() + + override fun visitNewSubscriptionMaxGroupTieredPackage( + newSubscriptionMaxGroupTieredPackage: + NewSubscriptionMaxGroupTieredPackagePrice + ) = newSubscriptionMaxGroupTieredPackage.validity() + + override fun visitNewSubscriptionGroupedWithMeteredMinimum( + newSubscriptionGroupedWithMeteredMinimum: + NewSubscriptionGroupedWithMeteredMinimumPrice + ) = newSubscriptionGroupedWithMeteredMinimum.validity() + + override fun visitNewSubscriptionMatrixWithDisplayName( + newSubscriptionMatrixWithDisplayName: + NewSubscriptionMatrixWithDisplayNamePrice + ) = newSubscriptionMatrixWithDisplayName.validity() + + override fun visitNewSubscriptionGroupedTieredPackage( + newSubscriptionGroupedTieredPackage: + NewSubscriptionGroupedTieredPackagePrice + ) = newSubscriptionGroupedTieredPackage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66673,247 +73556,221 @@ private constructor( when (modelType) { "unit" -> { - return Price( - newSubscriptionUnit = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionUnit = it, _json = json) } + ?: Price(_json = json) } "package" -> { - return Price( - newSubscriptionPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionPackage = it, _json = json) } + ?: Price(_json = json) } "matrix" -> { - return Price( - newSubscriptionMatrix = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionMatrix = it, _json = json) } + ?: Price(_json = json) } "tiered" -> { - return Price( - newSubscriptionTiered = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTiered = it, _json = json) } + ?: Price(_json = json) } "tiered_bps" -> { - return Price( - newSubscriptionTieredBps = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredBps = it, _json = json) } + ?: Price(_json = json) } "bps" -> { - return Price( - newSubscriptionBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionBps = it, _json = json) } + ?: Price(_json = json) } "bulk_bps" -> { - return Price( - newSubscriptionBulkBps = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionBulkBps = it, _json = json) } + ?: Price(_json = json) } "bulk" -> { - return Price( - newSubscriptionBulk = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionBulk = it, _json = json) } + ?: Price(_json = json) } "threshold_total_amount" -> { - return Price( - newSubscriptionThresholdTotalAmount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionThresholdTotalAmount = it, _json = json) + } ?: Price(_json = json) } "tiered_package" -> { - return Price( - newSubscriptionTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredPackage = it, _json = json) } + ?: Price(_json = json) } "tiered_with_minimum" -> { - return Price( - newSubscriptionTieredWithMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } "unit_with_percent" -> { - return Price( - newSubscriptionUnitWithPercent = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionUnitWithPercent = it, _json = json) } + ?: Price(_json = json) } "package_with_allocation" -> { - return Price( - newSubscriptionPackageWithAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionPackageWithAllocation = it, _json = json) + } ?: Price(_json = json) } "tiered_with_proration" -> { - return Price( - newSubscriptionTierWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTierWithProration = it, _json = json) } + ?: Price(_json = json) } "unit_with_proration" -> { - return Price( - newSubscriptionUnitWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionUnitWithProration = it, _json = json) } + ?: Price(_json = json) } "grouped_allocation" -> { - return Price( - newSubscriptionGroupedAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionGroupedAllocation = it, _json = json) } + ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return Price( - newSubscriptionGroupedWithProratedMinimum = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionGroupedWithProratedMinimumPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newSubscriptionGroupedWithProratedMinimum = it, + _json = json, + ) + } ?: Price(_json = json) } "bulk_with_proration" -> { - return Price( - newSubscriptionBulkWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionBulkWithProration = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return Price( - newSubscriptionScalableMatrixWithUnitPricing = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { + Price( + newSubscriptionScalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return Price( - newSubscriptionScalableMatrixWithTieredPricing = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { + Price( + newSubscriptionScalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return Price( - newSubscriptionCumulativeGroupedBulk = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionCumulativeGroupedBulk = it, _json = json) + } ?: Price(_json = json) } "max_group_tiered_package" -> { - return Price( - newSubscriptionMaxGroupTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionMaxGroupTieredPackage = it, _json = json) + } ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return Price( - newSubscriptionGroupedWithMeteredMinimum = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionGroupedWithMeteredMinimumPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newSubscriptionGroupedWithMeteredMinimum = it, + _json = json, + ) + } ?: Price(_json = json) } "matrix_with_display_name" -> { - return Price( - newSubscriptionMatrixWithDisplayName = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionMatrixWithDisplayName = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered_package" -> { - return Price( - newSubscriptionGroupedTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionGroupedTieredPackage = it, _json = json) + } ?: Price(_json = json) } } @@ -67884,9 +74741,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitConfig().validate() billableMetricId() @@ -67903,6 +74760,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -68021,6 +74911,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -68122,6 +75040,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -68271,6 +75217,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -68470,10 +75433,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -68571,6 +75553,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -68756,241 +75766,308 @@ private constructor( } /** - * Returns an immutable instance of [InvoicingCycleConfiguration]. + * Returns an immutable instance of [InvoicingCycleConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoicingCycleConfiguration = + InvoicingCycleConfiguration( + checkRequired("duration", duration), + checkRequired("durationUnit", durationUnit), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (validated) { + return@apply + } + + duration() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + + /** The unit of billing period duration. */ + class DurationUnit + @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 { + + @JvmField val DAY = of("day") + + @JvmField val MONTH = of("month") + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + /** An enum containing [DurationUnit]'s known values. */ + enum class Known { + DAY, + MONTH, + } + + /** + * An enum containing [DurationUnit]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [DurationUnit] 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 { + DAY, + MONTH, + /** + * An enum member indicating that [DurationUnit] 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) { + DAY -> Value.DAY + MONTH -> Value.MONTH + 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) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> + throw OrbInvalidDataException("Unknown DurationUnit: $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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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. - * - * The following fields are required: - * ```java - * .duration() - * .durationUnit() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): InvoicingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } - /** The unit of billing period duration. */ - class DurationUnit - @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 { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] 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 { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] 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) { - DAY -> Value.DAY - MONTH -> Value.MONTH - 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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $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().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - 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 + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - validated = true - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -69923,9 +77000,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageConfig().validate() billableMetricId() @@ -69942,6 +77019,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -70060,6 +77170,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70161,6 +77299,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70359,6 +77525,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70558,10 +77743,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -70659,6 +77863,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70872,10 +78104,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -70973,6 +78224,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -71079,6 +78358,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72011,10 +79310,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -72030,6 +79329,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -72148,6 +79480,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72420,6 +79780,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -72627,6 +80010,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72751,6 +80154,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72945,10 +80376,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -73046,6 +80496,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73259,10 +80737,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -73360,6 +80857,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73466,6 +80991,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74398,9 +81943,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredConfig().validate() billableMetricId() @@ -74417,6 +81962,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -74535,6 +82113,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74636,6 +82242,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74800,6 +82434,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val firstUnit: JsonField, @@ -75039,6 +82691,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -75256,10 +82928,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -75357,6 +83048,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -75570,10 +83289,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -75671,6 +83409,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -75777,6 +83543,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76711,9 +84497,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredBpsConfig().validate() billableMetricId() @@ -76730,6 +84516,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -76848,6 +84667,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76949,6 +84796,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77117,6 +84992,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -77392,6 +85285,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77609,10 +85523,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -77710,6 +85643,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77923,10 +85884,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -78024,6 +86004,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -78130,6 +86138,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79061,9 +87089,9 @@ private constructor( } bpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -79079,6 +87107,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BpsConfig private constructor( private val bps: JsonField, @@ -79260,6 +87321,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79396,6 +87476,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79497,6 +87605,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79691,10 +87827,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -79792,6 +87947,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80005,10 +88188,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -80106,6 +88308,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80212,6 +88442,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81145,9 +89395,9 @@ private constructor( } bulkBpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -81163,6 +89413,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkBpsConfig private constructor( private val tiers: JsonField>, @@ -81317,6 +89600,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -81548,6 +89849,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81702,6 +90023,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81803,6 +90152,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81997,10 +90374,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -82098,6 +90494,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -82311,10 +90735,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -82412,6 +90855,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -82518,6 +90989,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83449,9 +91940,9 @@ private constructor( } bulkConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -83467,6 +91958,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkConfig private constructor( private val tiers: JsonField>, @@ -83616,6 +92140,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val unitAmount: JsonField, @@ -83811,6 +92353,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (maximumUnits.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83965,6 +92526,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84066,6 +92655,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84260,10 +92877,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -84361,6 +92997,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84574,10 +93238,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -84675,6 +93358,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84781,6 +93492,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -85725,9 +94456,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -85744,6 +94475,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -85862,6 +94626,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -85963,6 +94755,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86052,6 +94872,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86251,10 +95091,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -86352,6 +95211,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86565,10 +95452,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -86666,6 +95572,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86772,6 +95706,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87707,9 +96661,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredPackageConfig().validate() billableMetricId() @@ -87726,6 +96680,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -87844,6 +96831,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87945,6 +96960,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88033,6 +97076,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88232,10 +97295,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -88333,6 +97415,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88546,10 +97656,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -88647,6 +97776,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88753,6 +97910,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -89692,9 +98869,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithMinimumConfig().validate() billableMetricId() @@ -89711,6 +98888,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -89829,6 +99039,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -89930,6 +99168,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90019,6 +99285,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90218,10 +99504,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -90319,6 +99624,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90532,10 +99865,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -90633,6 +99985,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90739,6 +100119,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91675,9 +101075,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithPercentConfig().validate() billableMetricId() @@ -91694,6 +101094,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -91812,6 +101245,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91913,6 +101374,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -92001,6 +101490,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -92200,10 +101709,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -92301,6 +101829,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -92514,10 +102070,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -92615,6 +102190,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -92721,6 +102324,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93670,9 +103293,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageWithAllocationConfig().validate() billableMetricId() @@ -93689,6 +103312,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -93807,6 +103463,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93908,6 +103592,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93998,6 +103710,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94197,10 +103929,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -94298,6 +104049,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94511,10 +104290,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -94612,6 +104410,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94718,6 +104544,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95660,9 +105506,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithProrationConfig().validate() billableMetricId() @@ -95679,6 +105525,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -95797,6 +105676,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95898,6 +105805,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95987,6 +105922,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -96186,10 +106141,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -96287,6 +106261,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -96500,10 +106502,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -96601,6 +106622,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -96707,6 +106756,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97646,9 +107715,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithProrationConfig().validate() billableMetricId() @@ -97665,6 +107734,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -97783,6 +107885,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97884,6 +108014,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97973,6 +108131,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98172,10 +108350,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -98273,6 +108470,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98486,10 +108711,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -98587,6 +108831,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98693,6 +108965,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -99632,10 +109924,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedAllocationConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -99651,6 +109943,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -99769,6 +110094,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -99858,6 +110211,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -99964,6 +110337,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -100158,10 +110559,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -100259,6 +110679,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -100472,10 +110920,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -100573,6 +111040,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -100679,6 +111174,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -101643,10 +112158,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -101662,6 +112177,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -101780,6 +112328,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -101870,6 +112446,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -101977,6 +112573,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -102171,10 +112795,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -102272,6 +112915,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -102485,10 +113156,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -102586,6 +113276,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -102692,6 +113410,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -103632,9 +114370,9 @@ private constructor( } bulkWithProrationConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -103650,6 +114388,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkWithProrationConfig @JsonCreator private constructor( @@ -103726,6 +114497,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -103862,6 +114653,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -103963,6 +114782,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -104157,10 +115004,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -104258,6 +115124,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -104471,10 +115365,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -104572,6 +115485,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -104678,6 +115619,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -105647,9 +116608,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -105666,6 +116627,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -105784,6 +116779,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -105889,6 +116912,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -105980,6 +117031,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -106179,10 +117250,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -106280,6 +117370,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -106493,10 +117611,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -106594,6 +117731,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -106700,6 +117865,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -107670,9 +118855,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -107689,6 +118874,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -107807,6 +119026,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -107912,6 +119159,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -108006,6 +119281,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -108205,10 +119500,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -108306,6 +119620,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -108519,10 +119861,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -108620,6 +119981,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -108726,6 +120115,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -109675,10 +121084,10 @@ private constructor( return@apply } - cadence() + cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -109694,6 +121103,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -109812,6 +121254,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -109902,6 +121372,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -110008,6 +121498,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -110202,10 +121720,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -110303,6 +121840,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -110516,10 +122081,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -110617,6 +122201,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -110723,6 +122335,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -111672,10 +123304,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -111691,6 +123323,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -111809,6 +123474,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -111899,6 +123592,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -112005,6 +123718,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -112199,10 +123940,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -112300,6 +124060,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -112513,10 +124301,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -112614,6 +124421,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -112720,6 +124555,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -113683,10 +125538,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -113702,6 +125557,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -113820,6 +125708,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -113910,6 +125826,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -114017,6 +125953,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -114211,10 +126175,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -114312,6 +126295,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -114525,10 +126536,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -114626,6 +126656,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -114732,6 +126790,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -115681,10 +127759,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -115700,6 +127778,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -115818,6 +127929,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -115908,6 +128047,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -116014,6 +128173,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -116208,10 +128395,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -116309,6 +128515,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -116522,10 +128756,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -116623,6 +128876,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -116729,6 +129010,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -117673,10 +129974,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -117692,6 +129993,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -117810,6 +130144,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -117899,6 +130261,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -118005,6 +130387,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -118199,10 +130609,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -118300,6 +130729,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -118513,10 +130970,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -118614,6 +131090,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -118720,6 +131224,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt index a3ab48cc..57c2be98 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt @@ -1379,11 +1379,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1724,6 +1765,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1778,8 +1841,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1790,7 +1853,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1835,6 +1897,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1931,48 +2035,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2432,7 +2532,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2441,6 +2541,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2530,6 +2654,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2989,7 +3141,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -2998,6 +3150,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3087,6 +3263,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3549,7 +3753,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3558,6 +3762,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3647,6 +3875,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4144,7 +4400,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4154,6 +4410,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4243,6 +4524,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4701,7 +5010,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4710,6 +5019,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4799,6 +5132,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5078,6 +5439,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5126,14 +5507,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5160,6 +5540,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5227,23 +5636,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5658,12 +6063,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5751,6 +6179,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6175,13 +6630,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6269,6 +6747,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6692,13 +7197,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6786,6 +7314,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7051,6 +7606,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7412,6 +7988,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7501,6 +8099,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7861,6 +8477,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8653,6 +9291,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8859,6 +9525,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9096,6 +9782,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9204,6 +9910,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9343,6 +10076,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt index 3f1c79d7..2569032e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt @@ -365,6 +365,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ViewMode = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt index 7264a161..c7960c77 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt @@ -156,6 +156,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Data private constructor( private val perPriceCosts: JsonField>, @@ -449,6 +466,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (perPriceCosts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + class PerPriceCost private constructor( private val price: JsonField, @@ -891,6 +930,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt index a5568358..8e80ac46 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.SubscriptionService import java.util.Collections import java.util.Objects @@ -135,6 +136,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt index 178cb72c..5d071cec 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.SubscriptionServiceAsync import java.util.Collections import java.util.Objects @@ -137,6 +138,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt index ea552356..a8bfdbed 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt @@ -250,6 +250,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class Plan private constructor( private val id: JsonField, @@ -463,6 +483,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt index 363f8789..89a711c3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt @@ -629,6 +629,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Granularity = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -731,6 +758,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ViewMode = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt index a7b30ca6..46926aba 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.blocking.SubscriptionService import java.util.Collections import java.util.Objects @@ -138,6 +139,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt index ca29bef6..a137e4da 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt @@ -10,6 +10,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.errors.OrbInvalidDataException import com.withorb.api.services.async.SubscriptionServiceAsync import java.util.Collections import java.util.Objects @@ -140,6 +141,14 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt index 53227dba..740d0492 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt @@ -430,6 +430,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 659ec53c..8c3b5c54 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -21,6 +21,7 @@ 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.allMaxBy import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow @@ -849,6 +850,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (add.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (addAdjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (allowInvoiceCreditOrVoid.asKnown().isPresent) 1 else 0) + + (edit.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (editAdjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1898,6 +1921,36 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (startDate.asKnown().getOrNull()?.validity() ?: 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (endDate.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + /** * The start date of the price interval. This is the date that the price will start billing * on the subscription. @@ -1927,14 +1980,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { dateTime != null -> visitor.visitDateTime(dateTime) billingCycleRelative != null -> visitor.visitBillingCycleRelative(billingCycleRelative) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1949,12 +2001,42 @@ private constructor( override fun visitBillingCycleRelative( billingCycleRelative: BillingCycleRelativeDate - ) {} + ) { + billingCycleRelative.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2013,14 +2095,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StartDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StartDate(dateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return StartDate(billingCycleRelative = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { StartDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> StartDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return StartDate(_json = json) } } @@ -2299,12 +2394,33 @@ private constructor( } amount() - cadence() + cadence().validate() currency() expiresAtEndOfCadence() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expiresAtEndOfCadence.asKnown().isPresent) 1 else 0) + /** The cadence at which to allocate the amount to the customer. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2421,6 +2537,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2489,8 +2632,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amountDiscountCreationParams != null -> visitor.visitAmountDiscountCreationParams(amountDiscountCreationParams) percentageDiscountCreationParams != null -> @@ -2501,7 +2644,6 @@ private constructor( visitor.visitUsageDiscountCreationParams(usageDiscountCreationParams) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2534,6 +2676,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmountDiscountCreationParams( + amountDiscountCreationParams: AmountDiscountCreationParams + ) = amountDiscountCreationParams.validity() + + override fun visitPercentageDiscountCreationParams( + percentageDiscountCreationParams: PercentageDiscountCreationParams + ) = percentageDiscountCreationParams.validity() + + override fun visitUsageDiscountCreationParams( + usageDiscountCreationParams: UsageDiscountCreationParams + ) = usageDiscountCreationParams.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2616,34 +2792,29 @@ private constructor( when (discountType) { "amount" -> { - return Discount( - amountDiscountCreationParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Discount(amountDiscountCreationParams = it, _json = json) } + ?: Discount(_json = json) } "percentage" -> { - return Discount( - percentageDiscountCreationParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Discount(percentageDiscountCreationParams = it, _json = json) + } ?: Discount(_json = json) } "usage" -> { - return Discount( - usageDiscountCreationParams = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Discount(usageDiscountCreationParams = it, _json = json) } + ?: Discount(_json = json) } } @@ -2847,10 +3018,29 @@ private constructor( } amountDiscount() - discountType() + discountType().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2940,6 +3130,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3152,11 +3370,30 @@ private constructor( return@apply } - discountType() + discountType().validate() percentageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3246,6 +3483,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3456,11 +3721,30 @@ private constructor( return@apply } - discountType() + discountType().validate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3550,6 +3834,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3611,14 +3923,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { dateTime != null -> visitor.visitDateTime(dateTime) billingCycleRelative != null -> visitor.visitBillingCycleRelative(billingCycleRelative) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -3633,12 +3944,42 @@ private constructor( override fun visitBillingCycleRelative( billingCycleRelative: BillingCycleRelativeDate - ) {} + ) { + billingCycleRelative.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3697,14 +4038,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): EndDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return EndDate(dateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return EndDate(billingCycleRelative = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { EndDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> EndDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return EndDate(_json = json) } } @@ -3903,6 +4257,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4235,8 +4608,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newFloatingUnit != null -> visitor.visitNewFloatingUnit(newFloatingUnit) newFloatingPackage != null -> visitor.visitNewFloatingPackage(newFloatingPackage) @@ -4314,7 +4687,6 @@ private constructor( ) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -4496,6 +4868,142 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewFloatingUnit(newFloatingUnit: NewFloatingUnitPrice) = + newFloatingUnit.validity() + + override fun visitNewFloatingPackage( + newFloatingPackage: NewFloatingPackagePrice + ) = newFloatingPackage.validity() + + override fun visitNewFloatingMatrix( + newFloatingMatrix: NewFloatingMatrixPrice + ) = newFloatingMatrix.validity() + + override fun visitNewFloatingMatrixWithAllocation( + newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = newFloatingMatrixWithAllocation.validity() + + override fun visitNewFloatingTiered( + newFloatingTiered: NewFloatingTieredPrice + ) = newFloatingTiered.validity() + + override fun visitNewFloatingTieredBps( + newFloatingTieredBps: NewFloatingTieredBpsPrice + ) = newFloatingTieredBps.validity() + + override fun visitNewFloatingBps(newFloatingBps: NewFloatingBpsPrice) = + newFloatingBps.validity() + + override fun visitNewFloatingBulkBps( + newFloatingBulkBps: NewFloatingBulkBpsPrice + ) = newFloatingBulkBps.validity() + + override fun visitNewFloatingBulk(newFloatingBulk: NewFloatingBulkPrice) = + newFloatingBulk.validity() + + override fun visitNewFloatingThresholdTotalAmount( + newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice + ) = newFloatingThresholdTotalAmount.validity() + + override fun visitNewFloatingTieredPackage( + newFloatingTieredPackage: NewFloatingTieredPackagePrice + ) = newFloatingTieredPackage.validity() + + override fun visitNewFloatingGroupedTiered( + newFloatingGroupedTiered: NewFloatingGroupedTieredPrice + ) = newFloatingGroupedTiered.validity() + + override fun visitNewFloatingMaxGroupTieredPackage( + newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = newFloatingMaxGroupTieredPackage.validity() + + override fun visitNewFloatingTieredWithMinimum( + newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice + ) = newFloatingTieredWithMinimum.validity() + + override fun visitNewFloatingPackageWithAllocation( + newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = newFloatingPackageWithAllocation.validity() + + override fun visitNewFloatingTieredPackageWithMinimum( + newFloatingTieredPackageWithMinimum: + NewFloatingTieredPackageWithMinimumPrice + ) = newFloatingTieredPackageWithMinimum.validity() + + override fun visitNewFloatingUnitWithPercent( + newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice + ) = newFloatingUnitWithPercent.validity() + + override fun visitNewFloatingTieredWithProration( + newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice + ) = newFloatingTieredWithProration.validity() + + override fun visitNewFloatingUnitWithProration( + newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice + ) = newFloatingUnitWithProration.validity() + + override fun visitNewFloatingGroupedAllocation( + newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice + ) = newFloatingGroupedAllocation.validity() + + override fun visitNewFloatingGroupedWithProratedMinimum( + newFloatingGroupedWithProratedMinimum: + NewFloatingGroupedWithProratedMinimumPrice + ) = newFloatingGroupedWithProratedMinimum.validity() + + override fun visitNewFloatingGroupedWithMeteredMinimum( + newFloatingGroupedWithMeteredMinimum: + NewFloatingGroupedWithMeteredMinimumPrice + ) = newFloatingGroupedWithMeteredMinimum.validity() + + override fun visitNewFloatingMatrixWithDisplayName( + newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + ) = newFloatingMatrixWithDisplayName.validity() + + override fun visitNewFloatingBulkWithProration( + newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice + ) = newFloatingBulkWithProration.validity() + + override fun visitNewFloatingGroupedTieredPackage( + newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice + ) = newFloatingGroupedTieredPackage.validity() + + override fun visitNewFloatingScalableMatrixWithUnitPricing( + newFloatingScalableMatrixWithUnitPricing: + NewFloatingScalableMatrixWithUnitPricingPrice + ) = newFloatingScalableMatrixWithUnitPricing.validity() + + override fun visitNewFloatingScalableMatrixWithTieredPricing( + newFloatingScalableMatrixWithTieredPricing: + NewFloatingScalableMatrixWithTieredPricingPrice + ) = newFloatingScalableMatrixWithTieredPricing.validity() + + override fun visitNewFloatingCumulativeGroupedBulk( + newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice + ) = newFloatingCumulativeGroupedBulk.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4842,264 +5350,217 @@ private constructor( when (modelType) { "unit" -> { - return Price( - newFloatingUnit = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newFloatingUnit = it, _json = json) } + ?: Price(_json = json) } "package" -> { - return Price( - newFloatingPackage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newFloatingPackage = it, _json = json) } + ?: Price(_json = json) } "matrix" -> { - return Price( - newFloatingMatrix = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newFloatingMatrix = it, _json = json) } + ?: Price(_json = json) } "matrix_with_allocation" -> { - return Price( - newFloatingMatrixWithAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingMatrixWithAllocation = it, _json = json) } + ?: Price(_json = json) } "tiered" -> { - return Price( - newFloatingTiered = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newFloatingTiered = it, _json = json) } + ?: Price(_json = json) } "tiered_bps" -> { - return Price( - newFloatingTieredBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newFloatingTieredBps = it, _json = json) } + ?: Price(_json = json) } "bps" -> { - return Price( - newFloatingBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newFloatingBps = it, _json = json) } + ?: Price(_json = json) } "bulk_bps" -> { - return Price( - newFloatingBulkBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newFloatingBulkBps = it, _json = json) } + ?: Price(_json = json) } "bulk" -> { - return Price( - newFloatingBulk = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newFloatingBulk = it, _json = json) } + ?: Price(_json = json) } "threshold_total_amount" -> { - return Price( - newFloatingThresholdTotalAmount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingThresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } "tiered_package" -> { - return Price( - newFloatingTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingTieredPackage = it, _json = json) } + ?: Price(_json = json) } "grouped_tiered" -> { - return Price( - newFloatingGroupedTiered = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingGroupedTiered = it, _json = json) } + ?: Price(_json = json) } "max_group_tiered_package" -> { - return Price( - newFloatingMaxGroupTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingMaxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } "tiered_with_minimum" -> { - return Price( - newFloatingTieredWithMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingTieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } "package_with_allocation" -> { - return Price( - newFloatingPackageWithAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingPackageWithAllocation = it, _json = json) } + ?: Price(_json = json) } "tiered_package_with_minimum" -> { - return Price( - newFloatingTieredPackageWithMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newFloatingTieredPackageWithMinimum = it, _json = json) + } ?: Price(_json = json) } "unit_with_percent" -> { - return Price( - newFloatingUnitWithPercent = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingUnitWithPercent = it, _json = json) } + ?: Price(_json = json) } "tiered_with_proration" -> { - return Price( - newFloatingTieredWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingTieredWithProration = it, _json = json) } + ?: Price(_json = json) } "unit_with_proration" -> { - return Price( - newFloatingUnitWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingUnitWithProration = it, _json = json) } + ?: Price(_json = json) } "grouped_allocation" -> { - return Price( - newFloatingGroupedAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingGroupedAllocation = it, _json = json) } + ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return Price( - newFloatingGroupedWithProratedMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newFloatingGroupedWithProratedMinimum = it, _json = json) + } ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return Price( - newFloatingGroupedWithMeteredMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newFloatingGroupedWithMeteredMinimum = it, _json = json) + } ?: Price(_json = json) } "matrix_with_display_name" -> { - return Price( - newFloatingMatrixWithDisplayName = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingMatrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } "bulk_with_proration" -> { - return Price( - newFloatingBulkWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingBulkWithProration = it, _json = json) } + ?: Price(_json = json) } "grouped_tiered_package" -> { - return Price( - newFloatingGroupedTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingGroupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return Price( - newFloatingScalableMatrixWithUnitPricing = - deserialize( - node, - jacksonTypeRef< - NewFloatingScalableMatrixWithUnitPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newFloatingScalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return Price( - newFloatingScalableMatrixWithTieredPricing = - deserialize( - node, - jacksonTypeRef< - NewFloatingScalableMatrixWithTieredPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewFloatingScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { + Price( + newFloatingScalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return Price( - newFloatingCumulativeGroupedBulk = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newFloatingCumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } } @@ -6015,10 +6476,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() unitConfig().validate() billableMetricId() @@ -6033,6 +6494,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -6151,6 +6644,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6252,6 +6773,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6401,6 +6950,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6600,10 +7166,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -6701,6 +7286,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6914,10 +7527,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -7015,6 +7647,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7121,6 +7781,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7997,10 +8677,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() packageConfig().validate() billableMetricId() @@ -8015,6 +8695,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -8133,6 +8845,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8234,6 +8974,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8432,6 +9200,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8631,10 +9418,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -8732,6 +9538,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8945,10 +9779,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -9046,6 +9899,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9152,6 +10033,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10027,11 +10928,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() matrixConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -10045,6 +10946,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -10163,6 +11096,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10435,6 +11396,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -10642,6 +11626,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10766,6 +11770,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10960,10 +11992,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -11061,6 +12112,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11274,10 +12353,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -11375,6 +12473,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11481,6 +12607,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12366,11 +13512,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() matrixWithAllocationConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -12384,6 +13530,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -12502,6 +13680,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12830,6 +14036,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -13037,6 +14267,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13161,6 +14411,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13355,10 +14633,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -13456,6 +14753,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13669,10 +14994,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -13770,6 +15114,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13876,6 +15248,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14751,10 +16143,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredConfig().validate() billableMetricId() @@ -14769,6 +16161,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -14887,6 +16311,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14988,6 +16440,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15152,6 +16632,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val firstUnit: JsonField, @@ -15391,6 +16889,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15608,10 +17126,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -15709,6 +17246,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15922,10 +17487,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -16023,6 +17607,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16129,6 +17741,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17007,10 +18639,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredBpsConfig().validate() billableMetricId() @@ -17025,6 +18657,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -17143,6 +18807,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17244,6 +18936,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17412,6 +19132,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -17687,6 +19425,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17904,10 +19663,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -18005,6 +19783,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18218,10 +20024,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -18319,6 +20144,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18425,6 +20278,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19300,10 +21173,10 @@ private constructor( } bpsConfig().validate() - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -19317,6 +21190,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BpsConfig private constructor( private val bps: JsonField, @@ -19498,6 +21403,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19634,6 +21558,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19735,6 +21687,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19929,10 +21909,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -20030,6 +22029,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20243,10 +22270,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -20344,6 +22390,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20450,6 +22524,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21327,10 +23421,10 @@ private constructor( } bulkBpsConfig().validate() - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -21344,6 +23438,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkBpsConfig private constructor( private val tiers: JsonField>, @@ -21498,6 +23624,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -21729,6 +23873,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21883,6 +24047,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21984,6 +24176,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22178,10 +24398,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -22279,6 +24518,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22492,10 +24759,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -22593,6 +24879,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22699,6 +25013,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23574,10 +25908,10 @@ private constructor( } bulkConfig().validate() - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -23591,6 +25925,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkConfig private constructor( private val tiers: JsonField>, @@ -23740,6 +26106,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val unitAmount: JsonField, @@ -23935,6 +26319,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (maximumUnits.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24089,6 +26492,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24190,6 +26621,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24384,10 +26843,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24485,6 +26963,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24698,10 +27204,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24799,6 +27324,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24905,6 +27458,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25790,10 +28363,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -25808,6 +28381,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -25926,6 +28531,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26027,6 +28660,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26116,6 +28777,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26315,10 +28996,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26416,6 +29116,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26629,10 +29357,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26730,6 +29477,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26836,6 +29611,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27716,10 +30511,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredPackageConfig().validate() billableMetricId() @@ -27734,6 +30529,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -27852,6 +30679,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27953,6 +30808,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28041,6 +30924,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28240,10 +31143,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28341,6 +31263,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28554,10 +31504,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28655,6 +31624,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28761,6 +31758,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29641,11 +32658,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedTieredConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -29659,6 +32676,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -29777,6 +32826,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29865,6 +32942,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29971,6 +33068,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30165,10 +33290,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30266,6 +33410,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30479,10 +33651,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30580,6 +33771,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30686,6 +33905,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31578,11 +34817,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() maxGroupTieredPackageConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -31596,6 +34835,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -31714,6 +34985,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31804,6 +35103,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31910,6 +35229,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32104,10 +35451,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32205,6 +35571,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32418,10 +35812,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32519,6 +35932,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32625,6 +36066,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33506,10 +36967,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredWithMinimumConfig().validate() billableMetricId() @@ -33524,6 +36985,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -33642,6 +37135,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33743,6 +37264,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33832,6 +37381,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34031,10 +37600,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34132,6 +37720,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34345,10 +37961,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34446,6 +38081,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34552,6 +38215,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35444,10 +39127,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() packageWithAllocationConfig().validate() billableMetricId() @@ -35462,6 +39145,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -35580,6 +39295,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35681,6 +39424,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35771,6 +39542,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35970,10 +39761,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -36071,6 +39881,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36284,10 +40122,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -36385,6 +40242,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36491,6 +40376,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37387,10 +41292,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredPackageWithMinimumConfig().validate() billableMetricId() @@ -37405,6 +41310,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -37523,6 +41460,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37625,6 +41590,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37715,6 +41708,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37914,10 +41927,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -38015,6 +42047,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38228,10 +42288,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -38329,6 +42408,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38435,6 +42542,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39316,10 +43443,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() unitWithPercentConfig().validate() billableMetricId() @@ -39334,6 +43461,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -39452,6 +43611,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39553,6 +43740,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39641,6 +43856,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39840,10 +44075,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -39941,6 +44195,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40154,10 +44436,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -40255,6 +44556,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40361,6 +44690,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41245,10 +45594,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() tieredWithProrationConfig().validate() billableMetricId() @@ -41263,6 +45612,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -41381,6 +45762,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41482,6 +45891,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41571,6 +46008,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41770,10 +46227,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -41871,6 +46347,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42084,10 +46588,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -42185,6 +46708,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42291,6 +46842,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43172,10 +47743,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() unitWithProrationConfig().validate() billableMetricId() @@ -43190,6 +47761,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -43308,6 +47911,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43409,6 +48040,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43498,6 +48157,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43697,10 +48376,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -43798,6 +48496,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44011,10 +48737,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -44112,6 +48857,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44218,6 +48991,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45099,11 +49892,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedAllocationConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -45117,6 +49910,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -45235,6 +50060,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45324,6 +50177,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45430,6 +50303,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45624,10 +50525,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -45725,6 +50645,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45938,10 +50886,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -46039,6 +51006,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46145,6 +51140,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47050,11 +52065,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedWithProratedMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -47068,6 +52083,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -47186,6 +52233,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47276,6 +52351,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47383,6 +52478,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47577,10 +52700,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -47678,6 +52820,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47891,10 +53061,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -47992,6 +53181,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48098,6 +53315,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49001,11 +54238,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedWithMeteredMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -49019,6 +54256,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -49137,6 +54406,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49227,6 +54524,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49334,6 +54651,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49528,10 +54873,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -49629,6 +54993,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49842,10 +55234,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -49943,6 +55354,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50049,6 +55488,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50941,11 +56400,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() matrixWithDisplayNameConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -50959,6 +56418,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -51077,6 +56568,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51167,6 +56686,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51273,6 +56812,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51467,10 +57034,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -51568,6 +57154,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51781,10 +57395,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -51882,6 +57515,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51988,6 +57649,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52870,10 +58551,10 @@ private constructor( } bulkWithProrationConfig().validate() - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -52887,6 +58568,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + class BulkWithProrationConfig @JsonCreator private constructor( @@ -52963,6 +58676,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53099,6 +58832,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53200,6 +58961,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53394,10 +59183,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -53495,6 +59303,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53708,10 +59544,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -53809,6 +59664,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53915,6 +59798,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54800,11 +60703,11 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() groupedTieredPackageConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -54818,6 +60721,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -54936,6 +60871,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55025,6 +60988,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55131,6 +61114,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55325,10 +61336,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -55426,6 +61456,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55639,10 +61697,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -55740,6 +61817,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55846,6 +61951,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56759,10 +62884,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -56777,6 +62902,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -56895,6 +63053,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57000,6 +63186,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57091,6 +63305,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57290,10 +63524,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -57391,6 +63644,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57604,10 +63885,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -57705,6 +64005,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57811,6 +64139,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58725,10 +65073,10 @@ private constructor( return@apply } - cadence() + cadence().validate() currency() itemId() - modelType() + modelType().validate() name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -58743,6 +65091,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -58861,6 +65242,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58966,6 +65375,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59060,6 +65497,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59259,10 +65716,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -59360,6 +65836,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59573,10 +66077,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -59674,6 +66197,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59780,6 +66331,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60672,11 +67243,11 @@ private constructor( return@apply } - cadence() + cadence().validate() cumulativeGroupedBulkConfig().validate() currency() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -60690,6 +67261,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -60808,6 +67411,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60898,6 +67529,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61004,6 +67655,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61198,10 +67877,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -61299,6 +67997,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61484,241 +68210,308 @@ private constructor( } /** - * Returns an immutable instance of [InvoicingCycleConfiguration]. + * Returns an immutable instance of [InvoicingCycleConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoicingCycleConfiguration = + InvoicingCycleConfiguration( + checkRequired("duration", duration), + checkRequired("durationUnit", durationUnit), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (validated) { + return@apply + } + + duration() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + + /** The unit of billing period duration. */ + class DurationUnit + @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 { + + @JvmField val DAY = of("day") + + @JvmField val MONTH = of("month") + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + /** An enum containing [DurationUnit]'s known values. */ + enum class Known { + DAY, + MONTH, + } + + /** + * An enum containing [DurationUnit]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [DurationUnit] 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 { + DAY, + MONTH, + /** + * An enum member indicating that [DurationUnit] 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) { + DAY -> Value.DAY + MONTH -> Value.MONTH + 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) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> + throw OrbInvalidDataException("Unknown DurationUnit: $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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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. - * - * The following fields are required: - * ```java - * .duration() - * .durationUnit() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): InvoicingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } - /** The unit of billing period duration. */ - class DurationUnit - @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 { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] 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 { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] 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) { - DAY -> Value.DAY - MONTH -> Value.MONTH - 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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $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().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - 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 + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - validated = true - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62043,6 +68836,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (startDate.asKnown().getOrNull()?.validity() ?: 0) + + (endDate.asKnown().getOrNull()?.validity() ?: 0) + /** The definition of a new adjustment to create and add to the subscription. */ @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) @@ -62094,8 +68907,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newPercentageDiscount != null -> visitor.visitNewPercentageDiscount(newPercentageDiscount) newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) @@ -62104,7 +68917,6 @@ private constructor( newMaximum != null -> visitor.visitNewMaximum(newMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -62141,6 +68953,42 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewPercentageDiscount( + newPercentageDiscount: NewPercentageDiscount + ) = newPercentageDiscount.validity() + + override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = + newUsageDiscount.validity() + + override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = + newAmountDiscount.validity() + + override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + + override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62224,37 +69072,29 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return Adjustment( - newPercentageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(newPercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "usage_discount" -> { - return Adjustment( - newUsageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newUsageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - newAmountDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newAmountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - newMinimum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMinimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - newMaximum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMaximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -62566,13 +69406,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() percentageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -62662,6 +69523,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62972,13 +69861,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() usageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63068,6 +69978,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63379,13 +70317,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63475,6 +70434,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63823,7 +70810,7 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() itemId() minimumAmount() @@ -63831,6 +70818,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63920,6 +70929,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64229,13 +71266,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() maximumAmount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -64325,6 +71383,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64388,14 +71474,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { dateTime != null -> visitor.visitDateTime(dateTime) billingCycleRelative != null -> visitor.visitBillingCycleRelative(billingCycleRelative) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -64410,12 +71495,42 @@ private constructor( override fun visitBillingCycleRelative( billingCycleRelative: BillingCycleRelativeDate - ) {} + ) { + billingCycleRelative.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64474,14 +71589,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StartDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StartDate(dateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return StartDate(billingCycleRelative = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { StartDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> StartDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return StartDate(_json = json) } } @@ -64534,14 +71662,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { dateTime != null -> visitor.visitDateTime(dateTime) billingCycleRelative != null -> visitor.visitBillingCycleRelative(billingCycleRelative) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -64556,12 +71683,42 @@ private constructor( override fun visitBillingCycleRelative( billingCycleRelative: BillingCycleRelativeDate - ) {} + ) { + billingCycleRelative.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64620,14 +71777,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): EndDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return EndDate(dateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return EndDate(billingCycleRelative = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { EndDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> EndDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return EndDate(_json = json) } } @@ -65165,6 +72335,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (priceIntervalId.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (endDate.asKnown().getOrNull()?.validity() ?: 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (startDate.asKnown().getOrNull()?.validity() ?: 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + /** * The updated end date of this price interval. If not specified, the start date will not be * updated. @@ -65194,14 +72389,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { dateTime != null -> visitor.visitDateTime(dateTime) billingCycleRelative != null -> visitor.visitBillingCycleRelative(billingCycleRelative) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -65216,12 +72410,42 @@ private constructor( override fun visitBillingCycleRelative( billingCycleRelative: BillingCycleRelativeDate - ) {} + ) { + billingCycleRelative.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -65280,14 +72504,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): EndDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return EndDate(dateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return EndDate(billingCycleRelative = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { EndDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> EndDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return EndDate(_json = json) } } @@ -65486,6 +72723,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -65533,14 +72789,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { dateTime != null -> visitor.visitDateTime(dateTime) billingCycleRelative != null -> visitor.visitBillingCycleRelative(billingCycleRelative) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -65555,12 +72810,42 @@ private constructor( override fun visitBillingCycleRelative( billingCycleRelative: BillingCycleRelativeDate - ) {} + ) { + billingCycleRelative.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -65619,14 +72904,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StartDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StartDate(dateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return StartDate(billingCycleRelative = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { StartDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> StartDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return StartDate(_json = json) } } @@ -65903,6 +73201,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (adjustmentIntervalId.asKnown().isPresent) 1 else 0) + + (endDate.asKnown().getOrNull()?.validity() ?: 0) + + (startDate.asKnown().getOrNull()?.validity() ?: 0) + /** * The updated end date of this adjustment interval. If not specified, the start date will * not be updated. @@ -65932,14 +73250,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { dateTime != null -> visitor.visitDateTime(dateTime) billingCycleRelative != null -> visitor.visitBillingCycleRelative(billingCycleRelative) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -65954,12 +73271,42 @@ private constructor( override fun visitBillingCycleRelative( billingCycleRelative: BillingCycleRelativeDate - ) {} + ) { + billingCycleRelative.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66018,14 +73365,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): EndDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return EndDate(dateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return EndDate(billingCycleRelative = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { EndDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> EndDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return EndDate(_json = json) } } @@ -66076,14 +73436,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { dateTime != null -> visitor.visitDateTime(dateTime) billingCycleRelative != null -> visitor.visitBillingCycleRelative(billingCycleRelative) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -66098,12 +73457,42 @@ private constructor( override fun visitBillingCycleRelative( billingCycleRelative: BillingCycleRelativeDate - ) {} + ) { + billingCycleRelative.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66162,14 +73551,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StartDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StartDate(dateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return StartDate(billingCycleRelative = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { StartDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> StartDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return StartDate(_json = json) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt index 6ca9556c..36ac5269 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt @@ -1389,11 +1389,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1734,6 +1775,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1788,8 +1851,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1800,7 +1863,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1845,6 +1907,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1941,48 +2045,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2442,7 +2542,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2451,6 +2551,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2540,6 +2664,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2999,7 +3151,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3008,6 +3160,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3097,6 +3273,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3559,7 +3763,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3568,6 +3772,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3657,6 +3885,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4154,7 +4410,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4164,6 +4420,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4253,6 +4534,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4711,7 +5020,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4720,6 +5029,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4809,6 +5142,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5088,6 +5449,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5136,14 +5517,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5170,6 +5550,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5237,23 +5646,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5668,12 +6073,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5761,6 +6189,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6185,13 +6640,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6279,6 +6757,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6702,13 +7207,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6796,6 +7324,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7061,6 +7616,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7422,6 +7998,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7511,6 +8109,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7871,6 +8487,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8663,6 +9301,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8869,6 +9535,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9106,6 +9792,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9214,6 +9920,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9353,6 +10086,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 3ddc0603..447c6512 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -3111,12 +3111,12 @@ private constructor( return@apply } - changeOption() + changeOption().validate() addAdjustments().ifPresent { it.forEach { it.validate() } } addPrices().ifPresent { it.forEach { it.validate() } } alignBillingWithPlanChangeDate() autoCollection() - billingCycleAlignment() + billingCycleAlignment().ifPresent { it.validate() } billingCycleAnchorConfiguration().ifPresent { it.validate() } changeDate() couponRedemptionCode() @@ -3140,6 +3140,49 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (changeOption.asKnown().getOrNull()?.validity() ?: 0) + + (addAdjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (addPrices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (alignBillingWithPlanChangeDate.asKnown().isPresent) 1 else 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAlignment.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (changeDate.asKnown().isPresent) 1 else 0) + + (if (couponRedemptionCode.asKnown().isPresent) 1 else 0) + + (if (creditsOverageRate.asKnown().isPresent) 1 else 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (initialPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (if (perCreditOverageAmount.asKnown().isPresent) 1 else 0) + + (if (planId.asKnown().isPresent) 1 else 0) + + (if (planVersionNumber.asKnown().isPresent) 1 else 0) + + (priceOverrides.asKnown().getOrNull()?.size ?: 0) + + (removeAdjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (removePrices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (replaceAdjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (replacePrices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (trialDurationDays.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3251,6 +3294,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ChangeOption = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3570,6 +3640,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + /** The definition of a new adjustment to create and add to the subscription. */ @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) @@ -3621,8 +3712,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newPercentageDiscount != null -> visitor.visitNewPercentageDiscount(newPercentageDiscount) newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) @@ -3631,7 +3722,6 @@ private constructor( newMaximum != null -> visitor.visitNewMaximum(newMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -3668,6 +3758,42 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewPercentageDiscount( + newPercentageDiscount: NewPercentageDiscount + ) = newPercentageDiscount.validity() + + override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = + newUsageDiscount.validity() + + override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = + newAmountDiscount.validity() + + override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + + override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3751,37 +3877,29 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return Adjustment( - newPercentageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(newPercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "usage_discount" -> { - return Adjustment( - newUsageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newUsageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - newAmountDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newAmountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - newMinimum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMinimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - newMaximum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMaximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -4093,13 +4211,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() percentageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4189,6 +4328,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4499,13 +4666,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() usageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4595,6 +4783,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4906,13 +5122,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5002,6 +5239,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5350,7 +5615,7 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() itemId() minimumAmount() @@ -5358,6 +5623,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5447,6 +5734,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5756,13 +6071,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() maximumAmount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5852,6 +6188,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6714,6 +7078,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + /** The definition of a new allocation price to create and add to the subscription. */ class AllocationPrice private constructor( @@ -6971,12 +7362,33 @@ private constructor( } amount() - cadence() + cadence().validate() currency() expiresAtEndOfCadence() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expiresAtEndOfCadence.asKnown().isPresent) 1 else 0) + /** The cadence at which to allocate the amount to the customer. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -7093,6 +7505,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7421,13 +7860,34 @@ private constructor( return@apply } - discountType() + discountType().validate() amountDiscount() percentageDiscount() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -7527,6 +7987,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7876,8 +8363,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newSubscriptionUnit != null -> visitor.visitNewSubscriptionUnit(newSubscriptionUnit) newSubscriptionPackage != null -> @@ -7960,7 +8447,6 @@ private constructor( ) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -8135,6 +8621,138 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewSubscriptionUnit( + newSubscriptionUnit: NewSubscriptionUnitPrice + ) = newSubscriptionUnit.validity() + + override fun visitNewSubscriptionPackage( + newSubscriptionPackage: NewSubscriptionPackagePrice + ) = newSubscriptionPackage.validity() + + override fun visitNewSubscriptionMatrix( + newSubscriptionMatrix: NewSubscriptionMatrixPrice + ) = newSubscriptionMatrix.validity() + + override fun visitNewSubscriptionTiered( + newSubscriptionTiered: NewSubscriptionTieredPrice + ) = newSubscriptionTiered.validity() + + override fun visitNewSubscriptionTieredBps( + newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice + ) = newSubscriptionTieredBps.validity() + + override fun visitNewSubscriptionBps( + newSubscriptionBps: NewSubscriptionBpsPrice + ) = newSubscriptionBps.validity() + + override fun visitNewSubscriptionBulkBps( + newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice + ) = newSubscriptionBulkBps.validity() + + override fun visitNewSubscriptionBulk( + newSubscriptionBulk: NewSubscriptionBulkPrice + ) = newSubscriptionBulk.validity() + + override fun visitNewSubscriptionThresholdTotalAmount( + newSubscriptionThresholdTotalAmount: + NewSubscriptionThresholdTotalAmountPrice + ) = newSubscriptionThresholdTotalAmount.validity() + + override fun visitNewSubscriptionTieredPackage( + newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice + ) = newSubscriptionTieredPackage.validity() + + override fun visitNewSubscriptionTieredWithMinimum( + newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = newSubscriptionTieredWithMinimum.validity() + + override fun visitNewSubscriptionUnitWithPercent( + newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = newSubscriptionUnitWithPercent.validity() + + override fun visitNewSubscriptionPackageWithAllocation( + newSubscriptionPackageWithAllocation: + NewSubscriptionPackageWithAllocationPrice + ) = newSubscriptionPackageWithAllocation.validity() + + override fun visitNewSubscriptionTierWithProration( + newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice + ) = newSubscriptionTierWithProration.validity() + + override fun visitNewSubscriptionUnitWithProration( + newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice + ) = newSubscriptionUnitWithProration.validity() + + override fun visitNewSubscriptionGroupedAllocation( + newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = newSubscriptionGroupedAllocation.validity() + + override fun visitNewSubscriptionGroupedWithProratedMinimum( + newSubscriptionGroupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = newSubscriptionGroupedWithProratedMinimum.validity() + + override fun visitNewSubscriptionBulkWithProration( + newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = newSubscriptionBulkWithProration.validity() + + override fun visitNewSubscriptionScalableMatrixWithUnitPricing( + newSubscriptionScalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = newSubscriptionScalableMatrixWithUnitPricing.validity() + + override fun visitNewSubscriptionScalableMatrixWithTieredPricing( + newSubscriptionScalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = newSubscriptionScalableMatrixWithTieredPricing.validity() + + override fun visitNewSubscriptionCumulativeGroupedBulk( + newSubscriptionCumulativeGroupedBulk: + NewSubscriptionCumulativeGroupedBulkPrice + ) = newSubscriptionCumulativeGroupedBulk.validity() + + override fun visitNewSubscriptionMaxGroupTieredPackage( + newSubscriptionMaxGroupTieredPackage: + NewSubscriptionMaxGroupTieredPackagePrice + ) = newSubscriptionMaxGroupTieredPackage.validity() + + override fun visitNewSubscriptionGroupedWithMeteredMinimum( + newSubscriptionGroupedWithMeteredMinimum: + NewSubscriptionGroupedWithMeteredMinimumPrice + ) = newSubscriptionGroupedWithMeteredMinimum.validity() + + override fun visitNewSubscriptionMatrixWithDisplayName( + newSubscriptionMatrixWithDisplayName: + NewSubscriptionMatrixWithDisplayNamePrice + ) = newSubscriptionMatrixWithDisplayName.validity() + + override fun visitNewSubscriptionGroupedTieredPackage( + newSubscriptionGroupedTieredPackage: + NewSubscriptionGroupedTieredPackagePrice + ) = newSubscriptionGroupedTieredPackage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8474,247 +9092,221 @@ private constructor( when (modelType) { "unit" -> { - return Price( - newSubscriptionUnit = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionUnit = it, _json = json) } + ?: Price(_json = json) } "package" -> { - return Price( - newSubscriptionPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionPackage = it, _json = json) } + ?: Price(_json = json) } "matrix" -> { - return Price( - newSubscriptionMatrix = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionMatrix = it, _json = json) } + ?: Price(_json = json) } "tiered" -> { - return Price( - newSubscriptionTiered = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTiered = it, _json = json) } + ?: Price(_json = json) } "tiered_bps" -> { - return Price( - newSubscriptionTieredBps = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredBps = it, _json = json) } + ?: Price(_json = json) } "bps" -> { - return Price( - newSubscriptionBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionBps = it, _json = json) } + ?: Price(_json = json) } "bulk_bps" -> { - return Price( - newSubscriptionBulkBps = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionBulkBps = it, _json = json) } + ?: Price(_json = json) } "bulk" -> { - return Price( - newSubscriptionBulk = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionBulk = it, _json = json) } + ?: Price(_json = json) } "threshold_total_amount" -> { - return Price( - newSubscriptionThresholdTotalAmount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionThresholdTotalAmount = it, _json = json) + } ?: Price(_json = json) } "tiered_package" -> { - return Price( - newSubscriptionTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredPackage = it, _json = json) } + ?: Price(_json = json) } "tiered_with_minimum" -> { - return Price( - newSubscriptionTieredWithMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } "unit_with_percent" -> { - return Price( - newSubscriptionUnitWithPercent = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionUnitWithPercent = it, _json = json) } + ?: Price(_json = json) } "package_with_allocation" -> { - return Price( - newSubscriptionPackageWithAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionPackageWithAllocation = it, _json = json) + } ?: Price(_json = json) } "tiered_with_proration" -> { - return Price( - newSubscriptionTierWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTierWithProration = it, _json = json) } + ?: Price(_json = json) } "unit_with_proration" -> { - return Price( - newSubscriptionUnitWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionUnitWithProration = it, _json = json) } + ?: Price(_json = json) } "grouped_allocation" -> { - return Price( - newSubscriptionGroupedAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionGroupedAllocation = it, _json = json) } + ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return Price( - newSubscriptionGroupedWithProratedMinimum = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionGroupedWithProratedMinimumPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newSubscriptionGroupedWithProratedMinimum = it, + _json = json, + ) + } ?: Price(_json = json) } "bulk_with_proration" -> { - return Price( - newSubscriptionBulkWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionBulkWithProration = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return Price( - newSubscriptionScalableMatrixWithUnitPricing = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { + Price( + newSubscriptionScalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return Price( - newSubscriptionScalableMatrixWithTieredPricing = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { + Price( + newSubscriptionScalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return Price( - newSubscriptionCumulativeGroupedBulk = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionCumulativeGroupedBulk = it, _json = json) + } ?: Price(_json = json) } "max_group_tiered_package" -> { - return Price( - newSubscriptionMaxGroupTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionMaxGroupTieredPackage = it, _json = json) + } ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return Price( - newSubscriptionGroupedWithMeteredMinimum = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionGroupedWithMeteredMinimumPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newSubscriptionGroupedWithMeteredMinimum = it, + _json = json, + ) + } ?: Price(_json = json) } "matrix_with_display_name" -> { - return Price( - newSubscriptionMatrixWithDisplayName = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionMatrixWithDisplayName = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered_package" -> { - return Price( - newSubscriptionGroupedTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionGroupedTieredPackage = it, _json = json) + } ?: Price(_json = json) } } @@ -9685,9 +10277,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitConfig().validate() billableMetricId() @@ -9704,6 +10296,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -9822,6 +10447,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9923,6 +10576,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10072,6 +10753,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10271,10 +10969,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -10372,6 +11089,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10585,10 +11330,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -10686,6 +11450,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -10792,6 +11584,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11724,9 +12536,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageConfig().validate() billableMetricId() @@ -11743,6 +12555,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -11861,6 +12706,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -11962,6 +12835,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12160,6 +13061,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12359,10 +13279,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -12460,6 +13399,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12673,10 +13640,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -12774,6 +13760,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12880,6 +13894,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -13812,10 +14846,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -13831,6 +14865,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -13949,6 +15016,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14221,6 +15316,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -14428,6 +15546,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14552,6 +15690,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14746,10 +15912,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -14847,6 +16032,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15060,10 +16273,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -15161,6 +16393,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15267,6 +16527,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16199,9 +17479,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredConfig().validate() billableMetricId() @@ -16218,6 +17498,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -16336,6 +17649,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16437,6 +17778,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -16601,6 +17970,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val firstUnit: JsonField, @@ -16840,6 +18227,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17057,10 +18464,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -17158,6 +18584,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17371,10 +18825,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -17472,6 +18945,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17578,6 +19079,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18512,9 +20033,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredBpsConfig().validate() billableMetricId() @@ -18531,6 +20052,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -18649,6 +20203,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18750,6 +20332,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -18918,6 +20528,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -19193,6 +20821,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19410,10 +21059,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -19511,6 +21179,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19724,10 +21420,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -19825,6 +21540,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -19931,6 +21674,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20862,9 +22625,9 @@ private constructor( } bpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -20880,6 +22643,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BpsConfig private constructor( private val bps: JsonField, @@ -21061,6 +22857,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21197,6 +23012,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21298,6 +23141,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21492,10 +23363,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -21593,6 +23483,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -21806,10 +23724,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -21907,6 +23844,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22013,6 +23978,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -22946,9 +24931,9 @@ private constructor( } bulkBpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -22964,6 +24949,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkBpsConfig private constructor( private val tiers: JsonField>, @@ -23118,6 +25136,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -23349,6 +25385,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23503,6 +25559,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23604,6 +25688,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23798,10 +25910,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -23899,6 +26030,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24112,10 +26271,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -24213,6 +26391,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24319,6 +26525,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25250,9 +27476,9 @@ private constructor( } bulkConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -25268,6 +27494,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkConfig private constructor( private val tiers: JsonField>, @@ -25417,6 +27676,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val unitAmount: JsonField, @@ -25612,6 +27889,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (maximumUnits.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25766,6 +28062,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -25867,6 +28191,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26061,10 +28413,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26162,6 +28533,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26375,10 +28774,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -26476,6 +28894,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26582,6 +29028,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27526,9 +29992,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -27545,6 +30011,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -27663,6 +30162,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27764,6 +30291,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27853,6 +30408,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28052,10 +30627,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28153,6 +30747,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28366,10 +30988,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -28467,6 +31108,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28573,6 +31242,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29508,9 +32197,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredPackageConfig().validate() billableMetricId() @@ -29527,6 +32216,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -29645,6 +32367,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29746,6 +32496,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29834,6 +32612,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30033,10 +32831,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30134,6 +32951,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30347,10 +33192,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -30448,6 +33312,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30554,6 +33446,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31493,9 +34405,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithMinimumConfig().validate() billableMetricId() @@ -31512,6 +34424,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -31630,6 +34575,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31731,6 +34704,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -31820,6 +34821,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32019,10 +35040,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32120,6 +35160,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32333,10 +35401,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -32434,6 +35521,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32540,6 +35655,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33476,9 +36611,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithPercentConfig().validate() billableMetricId() @@ -33495,6 +36630,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -33613,6 +36781,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33714,6 +36910,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33802,6 +37026,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34001,10 +37245,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34102,6 +37365,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34315,10 +37606,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -34416,6 +37726,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -34522,6 +37860,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35471,9 +38829,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageWithAllocationConfig().validate() billableMetricId() @@ -35490,6 +38848,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -35608,6 +38999,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35709,6 +39128,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35799,6 +39246,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35998,10 +39465,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -36099,6 +39585,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36312,10 +39826,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -36413,6 +39946,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36519,6 +40080,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37461,9 +41042,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithProrationConfig().validate() billableMetricId() @@ -37480,6 +41061,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -37598,6 +41212,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37699,6 +41341,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37788,6 +41458,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37987,10 +41677,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -38088,6 +41797,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38301,10 +42038,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -38402,6 +42158,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -38508,6 +42292,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39447,9 +43251,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithProrationConfig().validate() billableMetricId() @@ -39466,6 +43270,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -39584,6 +43421,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39685,6 +43550,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39774,6 +43667,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39973,10 +43886,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -40074,6 +44006,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40287,10 +44247,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -40388,6 +44367,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40494,6 +44501,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41433,10 +45460,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedAllocationConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -41452,6 +45479,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -41570,6 +45630,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41659,6 +45747,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41765,6 +45873,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41959,10 +46095,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -42060,6 +46215,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42273,10 +46456,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -42374,6 +46576,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -42480,6 +46710,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43444,10 +47694,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -43463,6 +47713,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -43581,6 +47864,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43671,6 +47982,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43778,6 +48109,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43972,10 +48331,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -44073,6 +48451,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44286,10 +48692,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -44387,6 +48812,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -44493,6 +48946,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45433,9 +49906,9 @@ private constructor( } bulkWithProrationConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -45451,6 +49924,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkWithProrationConfig @JsonCreator private constructor( @@ -45527,6 +50033,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45663,6 +50189,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45764,6 +50318,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45958,10 +50540,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -46059,6 +50660,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46272,10 +50901,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -46373,6 +51021,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46479,6 +51155,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47448,9 +52144,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -47467,6 +52163,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -47585,6 +52315,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47690,6 +52448,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47781,6 +52567,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47980,10 +52786,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -48081,6 +52906,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48294,10 +53147,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -48395,6 +53267,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48501,6 +53401,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49471,9 +54391,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -49490,6 +54410,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -49608,6 +54562,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49713,6 +54695,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -49807,6 +54817,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50006,10 +55036,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -50107,6 +55156,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50320,10 +55397,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -50421,6 +55517,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50527,6 +55651,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51476,10 +56620,10 @@ private constructor( return@apply } - cadence() + cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -51495,6 +56639,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -51613,6 +56790,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51703,6 +56908,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51809,6 +57034,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52003,10 +57256,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -52104,6 +57376,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52317,10 +57617,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -52418,6 +57737,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -52524,6 +57871,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53473,10 +58840,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -53492,6 +58859,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -53610,6 +59010,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53700,6 +59128,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53806,6 +59254,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54000,10 +59476,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -54101,6 +59596,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54314,10 +59837,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -54415,6 +59957,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54521,6 +60091,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55484,10 +61074,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -55503,6 +61093,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -55621,6 +61244,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55711,6 +61362,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -55818,6 +61489,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56012,10 +61711,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -56113,6 +61831,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56326,10 +62072,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -56427,6 +62192,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56533,6 +62326,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57482,10 +63295,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -57501,6 +63314,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -57619,6 +63465,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57709,6 +63583,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -57815,6 +63709,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58009,10 +63931,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -58110,6 +64051,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58323,10 +64292,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -58424,6 +64412,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58530,6 +64546,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59474,10 +65510,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -59493,6 +65529,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -59611,6 +65680,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59700,6 +65797,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -59806,6 +65923,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60000,10 +66145,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -60101,6 +66265,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60314,10 +66506,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -60415,6 +66626,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60521,6 +66760,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60675,6 +66934,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): BillingCycleAlignment = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60917,6 +67203,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61066,6 +67372,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61239,6 +67562,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61460,6 +67802,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + /** The definition of a new adjustment to create and add to the subscription. */ @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) @@ -61511,8 +67872,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newPercentageDiscount != null -> visitor.visitNewPercentageDiscount(newPercentageDiscount) newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) @@ -61521,7 +67882,6 @@ private constructor( newMaximum != null -> visitor.visitNewMaximum(newMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -61558,6 +67918,42 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewPercentageDiscount( + newPercentageDiscount: NewPercentageDiscount + ) = newPercentageDiscount.validity() + + override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = + newUsageDiscount.validity() + + override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = + newAmountDiscount.validity() + + override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + + override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61641,37 +68037,29 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return Adjustment( - newPercentageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(newPercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "usage_discount" -> { - return Adjustment( - newUsageDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newUsageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - newAmountDiscount = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newAmountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - newMinimum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMinimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - newMaximum = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(newMaximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -61983,13 +68371,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() percentageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -62079,6 +68488,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62389,13 +68826,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() usageDiscount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -62485,6 +68943,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -62796,13 +69282,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -62892,6 +69399,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63240,7 +69775,7 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() itemId() minimumAmount() @@ -63248,6 +69783,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63337,6 +69894,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63646,13 +70231,34 @@ private constructor( return@apply } - adjustmentType() + adjustmentType().validate() appliesToPriceIds() maximumAmount() isInvoiceLevel() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63742,6 +70348,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64570,6 +71204,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + /** The definition of a new allocation price to create and add to the subscription. */ class AllocationPrice private constructor( @@ -64827,12 +71487,33 @@ private constructor( } amount() - cadence() + cadence().validate() currency() expiresAtEndOfCadence() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expiresAtEndOfCadence.asKnown().isPresent) 1 else 0) + /** The cadence at which to allocate the amount to the customer. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -64949,6 +71630,33 @@ private constructor( 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -65277,13 +71985,34 @@ private constructor( return@apply } - discountType() + discountType().validate() amountDiscount() percentageDiscount() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -65383,6 +72112,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -65732,8 +72488,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { newSubscriptionUnit != null -> visitor.visitNewSubscriptionUnit(newSubscriptionUnit) newSubscriptionPackage != null -> @@ -65816,7 +72572,6 @@ private constructor( ) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -65991,6 +72746,138 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNewSubscriptionUnit( + newSubscriptionUnit: NewSubscriptionUnitPrice + ) = newSubscriptionUnit.validity() + + override fun visitNewSubscriptionPackage( + newSubscriptionPackage: NewSubscriptionPackagePrice + ) = newSubscriptionPackage.validity() + + override fun visitNewSubscriptionMatrix( + newSubscriptionMatrix: NewSubscriptionMatrixPrice + ) = newSubscriptionMatrix.validity() + + override fun visitNewSubscriptionTiered( + newSubscriptionTiered: NewSubscriptionTieredPrice + ) = newSubscriptionTiered.validity() + + override fun visitNewSubscriptionTieredBps( + newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice + ) = newSubscriptionTieredBps.validity() + + override fun visitNewSubscriptionBps( + newSubscriptionBps: NewSubscriptionBpsPrice + ) = newSubscriptionBps.validity() + + override fun visitNewSubscriptionBulkBps( + newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice + ) = newSubscriptionBulkBps.validity() + + override fun visitNewSubscriptionBulk( + newSubscriptionBulk: NewSubscriptionBulkPrice + ) = newSubscriptionBulk.validity() + + override fun visitNewSubscriptionThresholdTotalAmount( + newSubscriptionThresholdTotalAmount: + NewSubscriptionThresholdTotalAmountPrice + ) = newSubscriptionThresholdTotalAmount.validity() + + override fun visitNewSubscriptionTieredPackage( + newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice + ) = newSubscriptionTieredPackage.validity() + + override fun visitNewSubscriptionTieredWithMinimum( + newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = newSubscriptionTieredWithMinimum.validity() + + override fun visitNewSubscriptionUnitWithPercent( + newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = newSubscriptionUnitWithPercent.validity() + + override fun visitNewSubscriptionPackageWithAllocation( + newSubscriptionPackageWithAllocation: + NewSubscriptionPackageWithAllocationPrice + ) = newSubscriptionPackageWithAllocation.validity() + + override fun visitNewSubscriptionTierWithProration( + newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice + ) = newSubscriptionTierWithProration.validity() + + override fun visitNewSubscriptionUnitWithProration( + newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice + ) = newSubscriptionUnitWithProration.validity() + + override fun visitNewSubscriptionGroupedAllocation( + newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = newSubscriptionGroupedAllocation.validity() + + override fun visitNewSubscriptionGroupedWithProratedMinimum( + newSubscriptionGroupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = newSubscriptionGroupedWithProratedMinimum.validity() + + override fun visitNewSubscriptionBulkWithProration( + newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = newSubscriptionBulkWithProration.validity() + + override fun visitNewSubscriptionScalableMatrixWithUnitPricing( + newSubscriptionScalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = newSubscriptionScalableMatrixWithUnitPricing.validity() + + override fun visitNewSubscriptionScalableMatrixWithTieredPricing( + newSubscriptionScalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = newSubscriptionScalableMatrixWithTieredPricing.validity() + + override fun visitNewSubscriptionCumulativeGroupedBulk( + newSubscriptionCumulativeGroupedBulk: + NewSubscriptionCumulativeGroupedBulkPrice + ) = newSubscriptionCumulativeGroupedBulk.validity() + + override fun visitNewSubscriptionMaxGroupTieredPackage( + newSubscriptionMaxGroupTieredPackage: + NewSubscriptionMaxGroupTieredPackagePrice + ) = newSubscriptionMaxGroupTieredPackage.validity() + + override fun visitNewSubscriptionGroupedWithMeteredMinimum( + newSubscriptionGroupedWithMeteredMinimum: + NewSubscriptionGroupedWithMeteredMinimumPrice + ) = newSubscriptionGroupedWithMeteredMinimum.validity() + + override fun visitNewSubscriptionMatrixWithDisplayName( + newSubscriptionMatrixWithDisplayName: + NewSubscriptionMatrixWithDisplayNamePrice + ) = newSubscriptionMatrixWithDisplayName.validity() + + override fun visitNewSubscriptionGroupedTieredPackage( + newSubscriptionGroupedTieredPackage: + NewSubscriptionGroupedTieredPackagePrice + ) = newSubscriptionGroupedTieredPackage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66330,247 +73217,221 @@ private constructor( when (modelType) { "unit" -> { - return Price( - newSubscriptionUnit = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionUnit = it, _json = json) } + ?: Price(_json = json) } "package" -> { - return Price( - newSubscriptionPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionPackage = it, _json = json) } + ?: Price(_json = json) } "matrix" -> { - return Price( - newSubscriptionMatrix = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionMatrix = it, _json = json) } + ?: Price(_json = json) } "tiered" -> { - return Price( - newSubscriptionTiered = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTiered = it, _json = json) } + ?: Price(_json = json) } "tiered_bps" -> { - return Price( - newSubscriptionTieredBps = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredBps = it, _json = json) } + ?: Price(_json = json) } "bps" -> { - return Price( - newSubscriptionBps = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionBps = it, _json = json) } + ?: Price(_json = json) } "bulk_bps" -> { - return Price( - newSubscriptionBulkBps = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionBulkBps = it, _json = json) } + ?: Price(_json = json) } "bulk" -> { - return Price( - newSubscriptionBulk = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(newSubscriptionBulk = it, _json = json) } + ?: Price(_json = json) } "threshold_total_amount" -> { - return Price( - newSubscriptionThresholdTotalAmount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionThresholdTotalAmount = it, _json = json) + } ?: Price(_json = json) } "tiered_package" -> { - return Price( - newSubscriptionTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredPackage = it, _json = json) } + ?: Price(_json = json) } "tiered_with_minimum" -> { - return Price( - newSubscriptionTieredWithMinimum = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } "unit_with_percent" -> { - return Price( - newSubscriptionUnitWithPercent = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionUnitWithPercent = it, _json = json) } + ?: Price(_json = json) } "package_with_allocation" -> { - return Price( - newSubscriptionPackageWithAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionPackageWithAllocation = it, _json = json) + } ?: Price(_json = json) } "tiered_with_proration" -> { - return Price( - newSubscriptionTierWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionTierWithProration = it, _json = json) } + ?: Price(_json = json) } "unit_with_proration" -> { - return Price( - newSubscriptionUnitWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionUnitWithProration = it, _json = json) } + ?: Price(_json = json) } "grouped_allocation" -> { - return Price( - newSubscriptionGroupedAllocation = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionGroupedAllocation = it, _json = json) } + ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return Price( - newSubscriptionGroupedWithProratedMinimum = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionGroupedWithProratedMinimumPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newSubscriptionGroupedWithProratedMinimum = it, + _json = json, + ) + } ?: Price(_json = json) } "bulk_with_proration" -> { - return Price( - newSubscriptionBulkWithProration = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(newSubscriptionBulkWithProration = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return Price( - newSubscriptionScalableMatrixWithUnitPricing = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { + Price( + newSubscriptionScalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return Price( - newSubscriptionScalableMatrixWithTieredPricing = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { + Price( + newSubscriptionScalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return Price( - newSubscriptionCumulativeGroupedBulk = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionCumulativeGroupedBulk = it, _json = json) + } ?: Price(_json = json) } "max_group_tiered_package" -> { - return Price( - newSubscriptionMaxGroupTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionMaxGroupTieredPackage = it, _json = json) + } ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return Price( - newSubscriptionGroupedWithMeteredMinimum = - deserialize( - node, - jacksonTypeRef< - NewSubscriptionGroupedWithMeteredMinimumPrice - >(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price( + newSubscriptionGroupedWithMeteredMinimum = it, + _json = json, + ) + } ?: Price(_json = json) } "matrix_with_display_name" -> { - return Price( - newSubscriptionMatrixWithDisplayName = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionMatrixWithDisplayName = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered_package" -> { - return Price( - newSubscriptionGroupedTieredPackage = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Price(newSubscriptionGroupedTieredPackage = it, _json = json) + } ?: Price(_json = json) } } @@ -67541,9 +74402,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitConfig().validate() billableMetricId() @@ -67560,6 +74421,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -67678,6 +74572,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67779,6 +74701,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67928,6 +74878,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -68127,10 +75094,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -68228,6 +75214,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -68413,241 +75427,308 @@ private constructor( } /** - * Returns an immutable instance of [InvoicingCycleConfiguration]. + * Returns an immutable instance of [InvoicingCycleConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoicingCycleConfiguration = + InvoicingCycleConfiguration( + checkRequired("duration", duration), + checkRequired("durationUnit", durationUnit), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (validated) { + return@apply + } + + duration() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + + /** The unit of billing period duration. */ + class DurationUnit + @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 { + + @JvmField val DAY = of("day") + + @JvmField val MONTH = of("month") + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + /** An enum containing [DurationUnit]'s known values. */ + enum class Known { + DAY, + MONTH, + } + + /** + * An enum containing [DurationUnit]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [DurationUnit] 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 { + DAY, + MONTH, + /** + * An enum member indicating that [DurationUnit] 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) { + DAY -> Value.DAY + MONTH -> Value.MONTH + 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) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> + throw OrbInvalidDataException("Unknown DurationUnit: $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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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. - * - * The following fields are required: - * ```java - * .duration() - * .durationUnit() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): InvoicingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } - /** The unit of billing period duration. */ - class DurationUnit - @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 { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] 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 { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] 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) { - DAY -> Value.DAY - MONTH -> Value.MONTH - 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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $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().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - 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 + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - validated = true - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -69580,9 +76661,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageConfig().validate() billableMetricId() @@ -69599,6 +76680,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -69717,6 +76831,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -69818,6 +76960,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70016,6 +77186,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70215,10 +77404,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -70316,6 +77524,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70529,10 +77765,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -70630,6 +77885,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70736,6 +78019,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -71668,10 +78971,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -71687,6 +78990,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -71805,6 +79141,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72077,6 +79441,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -72284,6 +79671,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72408,6 +79815,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72602,10 +80037,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -72703,6 +80157,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72916,10 +80398,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -73017,6 +80518,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73123,6 +80652,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74055,9 +81604,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredConfig().validate() billableMetricId() @@ -74074,6 +81623,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -74192,6 +81774,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74293,6 +81903,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74457,6 +82095,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val firstUnit: JsonField, @@ -74696,6 +82352,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -74913,10 +82589,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -75014,6 +82709,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -75227,10 +82950,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -75328,6 +83070,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -75434,6 +83204,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76368,9 +84158,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredBpsConfig().validate() billableMetricId() @@ -76387,6 +84177,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -76505,6 +84328,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76606,6 +84457,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76774,6 +84653,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -77049,6 +84946,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77266,10 +85184,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -77367,6 +85304,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77580,10 +85545,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -77681,6 +85665,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -77787,6 +85799,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -78718,9 +86750,9 @@ private constructor( } bpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -78736,6 +86768,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BpsConfig private constructor( private val bps: JsonField, @@ -78917,6 +86982,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79053,6 +87137,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79154,6 +87266,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79348,10 +87488,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -79449,6 +87608,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79662,10 +87849,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -79763,6 +87969,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79869,6 +88103,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80802,9 +89056,9 @@ private constructor( } bulkBpsConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -80820,6 +89074,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkBpsConfig private constructor( private val tiers: JsonField>, @@ -80974,6 +89261,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val bps: JsonField, @@ -81205,6 +89510,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bps.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81359,6 +89684,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81460,6 +89813,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81654,10 +90035,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -81755,6 +90155,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -81968,10 +90396,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -82069,6 +90516,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -82175,6 +90650,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83106,9 +91601,9 @@ private constructor( } bulkConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -83124,6 +91619,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkConfig private constructor( private val tiers: JsonField>, @@ -83273,6 +91801,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Tier private constructor( private val unitAmount: JsonField, @@ -83468,6 +92014,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (maximumUnits.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83622,6 +92187,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83723,6 +92316,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -83917,10 +92538,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -84018,6 +92658,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84231,10 +92899,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -84332,6 +93019,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -84438,6 +93153,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -85382,9 +94117,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -85401,6 +94136,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -85519,6 +94287,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -85620,6 +94416,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -85709,6 +94533,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -85908,10 +94752,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -86009,6 +94872,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86222,10 +95113,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -86323,6 +95233,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -86429,6 +95367,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87364,9 +96322,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredPackageConfig().validate() billableMetricId() @@ -87383,6 +96341,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -87501,6 +96492,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87602,6 +96621,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87690,6 +96737,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -87889,10 +96956,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -87990,6 +97076,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88203,10 +97317,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -88304,6 +97437,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88410,6 +97571,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -89349,9 +98530,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithMinimumConfig().validate() billableMetricId() @@ -89368,6 +98549,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -89486,6 +98700,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -89587,6 +98829,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -89676,6 +98946,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -89875,10 +99165,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -89976,6 +99285,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90189,10 +99526,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -90290,6 +99646,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -90396,6 +99780,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91332,9 +100736,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithPercentConfig().validate() billableMetricId() @@ -91351,6 +100755,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -91469,6 +100906,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91570,6 +101035,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91658,6 +101151,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91857,10 +101370,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -91958,6 +101490,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -92171,10 +101731,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -92272,6 +101851,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -92378,6 +101985,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93327,9 +102954,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() packageWithAllocationConfig().validate() billableMetricId() @@ -93346,6 +102973,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -93464,6 +103124,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93565,6 +103253,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93655,6 +103371,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -93854,10 +103590,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -93955,6 +103710,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94168,10 +103951,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -94269,6 +104071,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94375,6 +104205,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95317,9 +105167,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() tieredWithProrationConfig().validate() billableMetricId() @@ -95336,6 +105186,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -95454,6 +105337,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95555,6 +105466,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95644,6 +105583,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -95843,10 +105802,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -95944,6 +105922,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -96157,10 +106163,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -96258,6 +106283,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -96364,6 +106417,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97303,9 +107376,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() unitWithProrationConfig().validate() billableMetricId() @@ -97322,6 +107395,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -97440,6 +107546,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97541,6 +107675,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97630,6 +107792,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -97829,10 +108011,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -97930,6 +108131,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98143,10 +108372,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -98244,6 +108492,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -98350,6 +108626,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -99289,10 +109585,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedAllocationConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -99308,6 +109604,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -99426,6 +109755,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -99515,6 +109872,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -99621,6 +109998,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -99815,10 +110220,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -99916,6 +110340,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -100129,10 +110581,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -100230,6 +110701,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -100336,6 +110835,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -101300,10 +111819,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -101319,6 +111838,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -101437,6 +111989,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -101527,6 +112107,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -101634,6 +112234,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -101828,10 +112456,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -101929,6 +112576,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -102142,10 +112817,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -102243,6 +112937,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -102349,6 +113071,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -103289,9 +114031,9 @@ private constructor( } bulkWithProrationConfig().validate() - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -103307,6 +114049,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + class BulkWithProrationConfig @JsonCreator private constructor( @@ -103383,6 +114158,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -103519,6 +114314,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -103620,6 +114443,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -103814,10 +114665,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -103915,6 +114785,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -104128,10 +115026,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -104229,6 +115146,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -104335,6 +115280,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -105304,9 +116269,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -105323,6 +116288,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -105441,6 +116440,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -105546,6 +116573,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -105637,6 +116692,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -105836,10 +116911,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -105937,6 +117031,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -106150,10 +117272,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -106251,6 +117392,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -106357,6 +117526,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -107327,9 +118516,9 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() - modelType() + modelType().validate() name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -107346,6 +118535,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -107464,6 +118687,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -107569,6 +118820,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -107663,6 +118942,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -107862,10 +119161,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -107963,6 +119281,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -108176,10 +119522,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -108277,6 +119642,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -108383,6 +119776,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -109332,10 +120745,10 @@ private constructor( return@apply } - cadence() + cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -109351,6 +120764,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -109469,6 +120915,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -109559,6 +121033,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -109665,6 +121159,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -109859,10 +121381,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -109960,6 +121501,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -110173,10 +121742,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -110274,6 +121862,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -110380,6 +121996,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -111329,10 +122965,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -111348,6 +122984,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -111466,6 +123135,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -111556,6 +123253,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -111662,6 +123379,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -111856,10 +123601,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -111957,6 +123721,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -112170,10 +123962,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -112271,6 +124082,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -112377,6 +124216,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -113340,10 +125199,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -113359,6 +125218,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -113477,6 +125369,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -113567,6 +125487,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -113674,6 +125614,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -113868,10 +125836,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -113969,6 +125956,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -114182,10 +126197,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -114283,6 +126317,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -114389,6 +126451,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -115338,10 +127420,10 @@ private constructor( return@apply } - cadence() + cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -115357,6 +127439,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -115475,6 +127590,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -115565,6 +127708,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -115671,6 +127834,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -115865,10 +128056,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -115966,6 +128176,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -116179,10 +128417,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -116280,6 +128537,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -116386,6 +128671,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -117330,10 +129635,10 @@ private constructor( return@apply } - cadence() + cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType() + modelType().validate() name() billableMetricId() billedInAdvance() @@ -117349,6 +129654,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ class Cadence @JsonCreator @@ -117467,6 +129805,34 @@ private constructor( 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -117556,6 +129922,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -117662,6 +130048,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ModelType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -117856,10 +130270,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -117957,6 +130390,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -118170,10 +130631,29 @@ private constructor( } duration() - durationUnit() + durationUnit().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (durationUnit.asKnown().getOrNull()?.validity() ?: 0) + /** The unit of billing period duration. */ class DurationUnit @JsonCreator @@ -118271,6 +130751,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DurationUnit = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -118377,6 +130885,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt index ccfae2c7..fcaf320c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt @@ -1390,11 +1390,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1735,6 +1776,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1789,8 +1852,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1801,7 +1864,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1846,6 +1908,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1942,48 +2046,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2443,7 +2543,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2452,6 +2552,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2541,6 +2665,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3000,7 +3152,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3009,6 +3161,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3098,6 +3274,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3560,7 +3764,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3569,6 +3773,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3658,6 +3886,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4155,7 +4411,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4165,6 +4421,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4254,6 +4535,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4712,7 +5021,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4721,6 +5030,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4810,6 +5143,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5089,6 +5450,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5137,14 +5518,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5171,6 +5551,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5238,23 +5647,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5669,12 +6074,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5762,6 +6190,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6186,13 +6641,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6280,6 +6758,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6703,13 +7208,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6797,6 +7325,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7062,6 +7617,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7423,6 +7999,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7512,6 +8110,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7872,6 +8488,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8664,6 +9302,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8870,6 +9536,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9107,6 +9793,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9215,6 +9921,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9354,6 +10087,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt index 1b7cbb38..e18e5393 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt @@ -500,6 +500,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowInvoiceCreditOrVoid.asKnown().isPresent) 1 else 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt index 445fce51..fdad7ee4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt @@ -1387,11 +1387,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1732,6 +1773,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1786,8 +1849,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1798,7 +1861,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1843,6 +1905,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1939,48 +2043,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2440,7 +2540,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2449,6 +2549,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2538,6 +2662,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2997,7 +3149,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3006,6 +3158,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3095,6 +3271,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3557,7 +3761,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3566,6 +3770,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3655,6 +3883,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4152,7 +4408,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4162,6 +4418,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4251,6 +4532,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4709,7 +5018,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4718,6 +5027,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4807,6 +5140,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5086,6 +5447,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5134,14 +5515,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5168,6 +5548,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5235,23 +5644,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5666,12 +6071,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5759,6 +6187,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6183,13 +6638,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6277,6 +6755,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6700,13 +7205,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6794,6 +7322,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7059,6 +7614,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7420,6 +7996,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7509,6 +8107,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7869,6 +8485,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8661,6 +9299,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8867,6 +9533,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9104,6 +9790,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9212,6 +9918,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9351,6 +10084,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt index ec2f23c1..59d15a87 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt @@ -1396,11 +1396,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1741,6 +1782,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1795,8 +1858,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1807,7 +1870,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1852,6 +1914,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1948,48 +2052,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2449,7 +2549,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2458,6 +2558,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2547,6 +2671,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3006,7 +3158,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3015,6 +3167,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3104,6 +3280,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3566,7 +3770,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3575,6 +3779,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3664,6 +3892,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4161,7 +4417,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4171,6 +4427,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4260,6 +4541,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4718,7 +5027,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4727,6 +5036,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4816,6 +5149,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5095,6 +5456,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5143,14 +5524,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5177,6 +5557,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5244,23 +5653,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5675,12 +6080,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5768,6 +6196,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6192,13 +6647,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6286,6 +6764,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6709,13 +7214,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6803,6 +7331,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7068,6 +7623,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7429,6 +8005,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7518,6 +8116,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7878,6 +8494,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8670,6 +9308,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8876,6 +9542,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9113,6 +9799,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9221,6 +9927,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9360,6 +10093,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt index c8aea24c..ec0de8fd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt @@ -379,6 +379,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (priceId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt index 26cf319d..fd8e44e3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt @@ -1404,11 +1404,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1749,6 +1790,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1803,8 +1866,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1815,7 +1878,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1860,6 +1922,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1956,48 +2060,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2457,7 +2557,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2466,6 +2566,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2555,6 +2679,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3014,7 +3166,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3023,6 +3175,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3112,6 +3288,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3574,7 +3778,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3583,6 +3787,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3672,6 +3900,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4169,7 +4425,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4179,6 +4435,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4268,6 +4549,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4726,7 +5035,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4735,6 +5044,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4824,6 +5157,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5103,6 +5464,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5151,14 +5532,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5185,6 +5565,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5252,23 +5661,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5683,12 +6088,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5776,6 +6204,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6200,13 +6655,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6294,6 +6772,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6717,13 +7222,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6811,6 +7339,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7076,6 +7631,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7437,6 +8013,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7526,6 +8124,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7886,6 +8502,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8678,6 +9316,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8884,6 +9550,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9121,6 +9807,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9229,6 +9935,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9368,6 +10101,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt index f9acc535..3170dd23 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt @@ -1400,11 +1400,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1745,6 +1786,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1799,8 +1862,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1811,7 +1874,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1856,6 +1918,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1952,48 +2056,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2453,7 +2553,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2462,6 +2562,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2551,6 +2675,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3010,7 +3162,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3019,6 +3171,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3108,6 +3284,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3570,7 +3774,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3579,6 +3783,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3668,6 +3896,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4165,7 +4421,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4175,6 +4431,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4264,6 +4545,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4722,7 +5031,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4731,6 +5040,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4820,6 +5153,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5099,6 +5460,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5147,14 +5528,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5181,6 +5561,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5248,23 +5657,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5679,12 +6084,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5772,6 +6200,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6196,13 +6651,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6290,6 +6768,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6713,13 +7218,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6807,6 +7335,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7072,6 +7627,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7433,6 +8009,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7522,6 +8120,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7882,6 +8498,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8674,6 +9312,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8880,6 +9546,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9117,6 +9803,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9225,6 +9931,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9364,6 +10097,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt index 0c63d892..8894b276 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt @@ -744,11 +744,33 @@ private constructor( priceId() quantity() allowInvoiceCreditOrVoid() - changeOption() + changeOption().ifPresent { it.validate() } effectiveDate() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (allowInvoiceCreditOrVoid.asKnown().isPresent) 1 else 0) + + (changeOption.asKnown().getOrNull()?.validity() ?: 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -865,6 +887,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ChangeOption = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt index 05279159..3362ae34 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt @@ -1396,11 +1396,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1741,6 +1782,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1795,8 +1858,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1807,7 +1870,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1852,6 +1914,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1948,48 +2052,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2449,7 +2549,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2458,6 +2558,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2547,6 +2671,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3006,7 +3158,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3015,6 +3167,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3104,6 +3280,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3566,7 +3770,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3575,6 +3779,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3664,6 +3892,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4161,7 +4417,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4171,6 +4427,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4260,6 +4541,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4718,7 +5027,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4727,6 +5036,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4816,6 +5149,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5095,6 +5456,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5143,14 +5524,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5177,6 +5557,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5244,23 +5653,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5675,12 +6080,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5768,6 +6196,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6192,13 +6647,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6286,6 +6764,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6709,13 +7214,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6803,6 +7331,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7068,6 +7623,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7429,6 +8005,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7518,6 +8116,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7878,6 +8494,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8670,6 +9308,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8876,6 +9542,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9113,6 +9799,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9221,6 +9927,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9360,6 +10093,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt index 0740864b..b28f9e2b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt @@ -778,6 +778,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -867,6 +889,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt index 56eba711..39da5e6e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt @@ -21,6 +21,7 @@ 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.allMaxBy import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers @@ -30,6 +31,7 @@ import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to update the trial end date for a subscription. The new trial end date @@ -511,6 +513,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (trialEndDate.asKnown().getOrNull()?.validity() ?: 0) + + (if (shift.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -556,13 +577,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) unionMember1 != null -> visitor.visitUnionMember1(unionMember1) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -575,12 +595,41 @@ private constructor( object : Visitor { override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) {} - override fun visitUnionMember1(unionMember1: UnionMember1) {} + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -640,14 +689,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): TrialEndDate { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return TrialEndDate(offsetDateTime = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return TrialEndDate(unionMember1 = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TrialEndDate(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TrialEndDate(offsetDateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> TrialEndDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return TrialEndDate(_json = json) } } @@ -750,6 +813,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): UnionMember1 = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt index 53e3efab..b37782b3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt @@ -1387,11 +1387,52 @@ private constructor( priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() - status() + status().validate() trialInfo().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + class AdjustmentInterval private constructor( private val id: JsonField, @@ -1732,6 +1773,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment @@ -1786,8 +1849,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { planPhaseUsageDiscount != null -> visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) planPhaseAmountDiscount != null -> @@ -1798,7 +1861,6 @@ private constructor( planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1843,6 +1905,48 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1939,48 +2043,44 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return Adjustment( - planPhaseUsageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "amount_discount" -> { - return Adjustment( - planPhaseAmountDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "percentage_discount" -> { - return Adjustment( - planPhasePercentageDiscount = - deserialize( - node, - jacksonTypeRef(), - ), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return Adjustment( - planPhaseMinimum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) } "maximum" -> { - return Adjustment( - planPhaseMaximum = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) } } @@ -2440,7 +2540,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2449,6 +2549,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2538,6 +2662,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2997,7 +3149,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3006,6 +3158,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3095,6 +3271,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3557,7 +3761,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3566,6 +3770,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3655,6 +3883,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4152,7 +4408,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() itemId() @@ -4162,6 +4418,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4251,6 +4532,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4709,7 +5018,7 @@ private constructor( } id() - adjustmentType() + adjustmentType().validate() appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4718,6 +5027,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class AdjustmentType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4807,6 +5140,34 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AdjustmentType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5086,6 +5447,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5134,14 +5515,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { amount != null -> visitor.visitAmount(amount) percentage != null -> visitor.visitPercentage(percentage) usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -5168,6 +5548,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5235,23 +5644,19 @@ private constructor( when (discountType) { "amount" -> { - return DiscountInterval( - amount = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return DiscountInterval( - percentage = - deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) } "usage" -> { - return DiscountInterval( - usage = deserialize(node, jacksonTypeRef()), - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -5666,12 +6071,35 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5759,6 +6187,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6183,13 +6638,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() percentageDiscount() 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6277,6 +6755,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6700,13 +7205,36 @@ private constructor( appliesToPriceIds() appliesToPriceIntervalIds() - discountType() + discountType().validate() endDate() startDate() usageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6794,6 +7322,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7059,6 +7614,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7420,6 +7996,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7509,6 +8107,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -7869,6 +8485,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8661,6 +9299,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + class FixedFeeQuantityTransition private constructor( private val effectiveDate: JsonField, @@ -8867,6 +9533,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9104,6 +9790,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9212,6 +9918,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9351,6 +10084,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt index 26f37d27..9626c42d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt @@ -20,6 +20,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.allMaxBy import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow @@ -54,13 +55,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { ungrouped != null -> visitor.visitUngrouped(ungrouped) grouped != null -> visitor.visitGrouped(grouped) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -83,6 +83,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUngrouped(ungrouped: UngroupedSubscriptionUsage) = + ungrouped.validity() + + override fun visitGrouped(grouped: GroupedSubscriptionUsage) = grouped.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -141,16 +167,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): SubscriptionUsage { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return SubscriptionUsage(ungrouped = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return SubscriptionUsage(grouped = it, _json = json) - } - - return SubscriptionUsage(_json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + SubscriptionUsage(ungrouped = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + SubscriptionUsage(grouped = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> SubscriptionUsage(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } } } @@ -307,6 +344,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Data private constructor( private val billableMetric: JsonField, @@ -523,10 +578,30 @@ private constructor( billableMetric().validate() usage().forEach { it.validate() } - viewMode() + viewMode().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (usage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (viewMode.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -686,6 +761,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -916,6 +1010,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1025,6 +1139,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ViewMode = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1255,6 +1396,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + class Data private constructor( private val billableMetric: JsonField, @@ -1511,10 +1671,31 @@ private constructor( billableMetric().validate() metricGroup().validate() usage().forEach { it.validate() } - viewMode() + viewMode().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. + */ + @JvmSynthetic + internal fun validity(): Int = + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (metricGroup.asKnown().getOrNull()?.validity() ?: 0) + + (usage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (viewMode.asKnown().getOrNull()?.validity() ?: 0) + class BillableMetric private constructor( private val id: JsonField, @@ -1674,6 +1855,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1865,6 +2065,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2095,6 +2314,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (timeframeEnd.asKnown().isPresent) 1 else 0) + + (if (timeframeStart.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2204,6 +2443,33 @@ private constructor( OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): ViewMode = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt index 2388e4b6..715ea132 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt @@ -16,6 +16,7 @@ import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull class Subscriptions private constructor( @@ -195,6 +196,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt index 726afeb6..08d21a9f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt @@ -135,6 +135,21 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (response.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt index 93696097..3fe8c295 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt @@ -343,13 +343,34 @@ private constructor( } appliesToPriceIds() - discountType() + discountType().validate() reason() trialAmountDiscount() trialPercentageDiscount() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (trialAmountDiscount.asKnown().isPresent) 1 else 0) + + (if (trialPercentageDiscount.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -431,6 +452,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt index 3a08bd27..a5e54d26 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt @@ -276,12 +276,32 @@ private constructor( } appliesToPriceIds() - discountType() + discountType().validate() usageDiscount() reason() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + class DiscountType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -363,6 +383,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): DiscountType = 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. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt index dcc7b907..f2f4b700 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt @@ -2,10 +2,15 @@ package com.withorb.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource import org.junitpioneer.jupiter.cartesian.CartesianTest internal class ObjectMappersTest { @@ -78,4 +83,20 @@ internal class ObjectMappersTest { assertThat(e).isInstanceOf(MismatchedInputException::class.java) } } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue(json) } + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt index 3641ba4d..9e004a26 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt @@ -2,6 +2,8 @@ package com.withorb.api.models +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -61,4 +63,39 @@ internal class AlertTest { .containsExactly(Alert.Threshold.builder().value(0.0).build()) assertThat(alert.type()).isEqualTo(Alert.Type.CREDIT_BALANCE_DEPLETED) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val alert = + Alert.builder() + .id("XuxCbt7x9L82yyeF") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .customer( + Alert.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .enabled(true) + .metric(Alert.Metric.builder().id("id").build()) + .plan( + Alert.Plan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .planVersion("plan_version") + .build() + ) + .subscription(Alert.Subscription.builder().id("VDGsT23osdLb84KD").build()) + .addThreshold(Alert.Threshold.builder().value(0.0).build()) + .type(Alert.Type.CREDIT_BALANCE_DEPLETED) + .build() + + val roundtrippedAlert = + jsonMapper.readValue(jsonMapper.writeValueAsString(alert), jacksonTypeRef()) + + assertThat(roundtrippedAlert).isEqualTo(alert) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountTest.kt index a1d20800..9a20ad5b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountTest.kt @@ -2,6 +2,8 @@ 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 @@ -24,4 +26,25 @@ internal class AmountDiscountTest { assertThat(amountDiscount.discountType()).isEqualTo(AmountDiscount.DiscountType.AMOUNT) assertThat(amountDiscount.reason()).contains("reason") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val amountDiscount = + AmountDiscount.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(AmountDiscount.DiscountType.AMOUNT) + .reason("reason") + .build() + + val roundtrippedAmountDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(amountDiscount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAmountDiscount).isEqualTo(amountDiscount) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt index 2a7eb959..57cf7e49 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt @@ -2,7 +2,9 @@ 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 @@ -66,4 +68,44 @@ internal class BillableMetricTest { assertThat(billableMetric.name()).isEqualTo("name") assertThat(billableMetric.status()).isEqualTo(BillableMetric.Status.ACTIVE) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val billableMetric = + BillableMetric.builder() + .id("id") + .description("description") + .item( + Item.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExternalConnection( + Item.ExternalConnection.builder() + .externalConnectionName( + Item.ExternalConnection.ExternalConnectionName.STRIPE + ) + .externalEntityId("external_entity_id") + .build() + ) + .name("name") + .build() + ) + .metadata( + BillableMetric.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .status(BillableMetric.Status.ACTIVE) + .build() + + val roundtrippedBillableMetric = + jsonMapper.readValue( + jsonMapper.writeValueAsString(billableMetric), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBillableMetric).isEqualTo(billableMetric) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponTest.kt index 74441d75..23b50895 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponTest.kt @@ -2,6 +2,8 @@ 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 @@ -48,4 +50,32 @@ internal class CouponTest { assertThat(coupon.redemptionCode()).isEqualTo("HALFOFF") assertThat(coupon.timesRedeemed()).isEqualTo(0L) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val coupon = + Coupon.builder() + .id("7iz2yanVjQoBZhyH") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .durationInMonths(12L) + .maxRedemptions(0L) + .redemptionCode("HALFOFF") + .timesRedeemed(0L) + .build() + + val roundtrippedCoupon = + jsonMapper.readValue(jsonMapper.writeValueAsString(coupon), jacksonTypeRef()) + + assertThat(roundtrippedCoupon).isEqualTo(coupon) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteTest.kt index 79ce7630..7e7ff433 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteTest.kt @@ -2,6 +2,8 @@ package com.withorb.api.models +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -166,4 +168,94 @@ internal class CreditNoteTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val creditNote = + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType(CreditNote.LineItem.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + + val roundtrippedCreditNote = + jsonMapper.readValue( + jsonMapper.writeValueAsString(creditNote), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCreditNote).isEqualTo(creditNote) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponseTest.kt index d7618f04..1f6ee1fa 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -53,4 +55,37 @@ internal class CustomerBalanceTransactionCreateResponseTest { assertThat(customerBalanceTransactionCreateResponse.type()) .isEqualTo(CustomerBalanceTransactionCreateResponse.Type.INCREMENT) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerBalanceTransactionCreateResponse = + CustomerBalanceTransactionCreateResponse.builder() + .id("cgZa3SXcsPTVyC4Y") + .action(CustomerBalanceTransactionCreateResponse.Action.APPLIED_TO_INVOICE) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + CustomerBalanceTransactionCreateResponse.CreditNote.builder().id("id").build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + CustomerBalanceTransactionCreateResponse.Invoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(CustomerBalanceTransactionCreateResponse.Type.INCREMENT) + .build() + + val roundtrippedCustomerBalanceTransactionCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerBalanceTransactionCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerBalanceTransactionCreateResponse) + .isEqualTo(customerBalanceTransactionCreateResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponseTest.kt index c0dc6264..26b7d39b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -51,4 +53,37 @@ internal class CustomerBalanceTransactionListResponseTest { assertThat(customerBalanceTransactionListResponse.type()) .isEqualTo(CustomerBalanceTransactionListResponse.Type.INCREMENT) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerBalanceTransactionListResponse = + CustomerBalanceTransactionListResponse.builder() + .id("cgZa3SXcsPTVyC4Y") + .action(CustomerBalanceTransactionListResponse.Action.APPLIED_TO_INVOICE) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + CustomerBalanceTransactionListResponse.CreditNote.builder().id("id").build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + CustomerBalanceTransactionListResponse.Invoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(CustomerBalanceTransactionListResponse.Type.INCREMENT) + .build() + + val roundtrippedCustomerBalanceTransactionListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerBalanceTransactionListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerBalanceTransactionListResponse) + .isEqualTo(customerBalanceTransactionListResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index a198d341..66de2ed2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -235,4 +237,135 @@ internal class CustomerCostListByExternalIdResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCostListByExternalIdResponse = + CustomerCostListByExternalIdResponse.builder() + .addData( + CustomerCostListByExternalIdResponse.Data.builder() + .addPerPriceCost( + CustomerCostListByExternalIdResponse.Data.PerPriceCost.builder() + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .priceId("price_id") + .subtotal("subtotal") + .total("total") + .quantity(0.0) + .build() + ) + .subtotal("subtotal") + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("total") + .build() + ) + .build() + + val roundtrippedCustomerCostListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCostListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCostListByExternalIdResponse) + .isEqualTo(customerCostListByExternalIdResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index 0754a7ff..df09c01f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -235,4 +237,134 @@ internal class CustomerCostListResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCostListResponse = + CustomerCostListResponse.builder() + .addData( + CustomerCostListResponse.Data.builder() + .addPerPriceCost( + CustomerCostListResponse.Data.PerPriceCost.builder() + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .priceId("price_id") + .subtotal("subtotal") + .total("total") + .quantity(0.0) + .build() + ) + .subtotal("subtotal") + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("total") + .build() + ) + .build() + + val roundtrippedCustomerCostListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCostListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCostListResponse).isEqualTo(customerCostListResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 886ea456..998e5f28 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -2,10 +2,16 @@ 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 com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { @@ -81,6 +87,67 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .isEmpty } + @Test + fun ofIncrementLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryByExternalIdResponse = + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofIncrementLedgerEntry( + CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry + .EntryType + .INCREMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse) + .isEqualTo(customerCreditLedgerCreateEntryByExternalIdResponse) + } + @Test fun ofDecrementLedgerEntry() { val decrementLedgerEntry = @@ -127,6 +194,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() ) .startingBalance(0.0) + .eventId("event_id") + .invoiceId("invoice_id") + .priceId("price_id") .build() val customerCreditLedgerCreateEntryByExternalIdResponse = @@ -153,6 +223,70 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .isEmpty } + @Test + fun ofDecrementLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryByExternalIdResponse = + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofDecrementLedgerEntry( + CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry + .EntryType + .DECREMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .eventId("event_id") + .invoiceId("invoice_id") + .priceId("price_id") + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse) + .isEqualTo(customerCreditLedgerCreateEntryByExternalIdResponse) + } + @Test fun ofExpirationChangeLedgerEntry() { val expirationChangeLedgerEntry = @@ -227,6 +361,74 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .isEmpty } + @Test + fun ofExpirationChangeLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryByExternalIdResponse = + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofExpirationChangeLedgerEntry( + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChangeLedgerEntry + .builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .ExpirationChangeLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .ExpirationChangeLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .ExpirationChangeLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .ExpirationChangeLedgerEntry + .EntryType + .EXPIRATION_CHANGE + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .ExpirationChangeLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .newBlockExpiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse) + .isEqualTo(customerCreditLedgerCreateEntryByExternalIdResponse) + } + @Test fun ofCreditBlockExpiryLedgerEntry() { val creditBlockExpiryLedgerEntry = @@ -300,6 +502,73 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .isEmpty } + @Test + fun ofCreditBlockExpiryLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryByExternalIdResponse = + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofCreditBlockExpiryLedgerEntry( + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiryLedgerEntry + .builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .CreditBlockExpiryLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .CreditBlockExpiryLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .CreditBlockExpiryLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .CreditBlockExpiryLedgerEntry + .EntryType + .CREDIT_BLOCK_EXPIRY + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryByExternalIdResponse + .CreditBlockExpiryLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse) + .isEqualTo(customerCreditLedgerCreateEntryByExternalIdResponse) + } + @Test fun ofVoidLedgerEntry() { val voidLedgerEntry = @@ -368,6 +637,67 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .isEmpty } + @Test + fun ofVoidLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryByExternalIdResponse = + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoidLedgerEntry( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry + .EntryType + .VOID + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .voidAmount(0.0) + .voidReason("void_reason") + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse) + .isEqualTo(customerCreditLedgerCreateEntryByExternalIdResponse) + } + @Test fun ofVoidInitiatedLedgerEntry() { val voidInitiatedLedgerEntry = @@ -443,6 +773,71 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .isEmpty } + @Test + fun ofVoidInitiatedLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryByExternalIdResponse = + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoidInitiatedLedgerEntry( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry + .builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry + .EntryType + .VOID_INITIATED + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .newBlockExpiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingBalance(0.0) + .voidAmount(0.0) + .voidReason("void_reason") + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse) + .isEqualTo(customerCreditLedgerCreateEntryByExternalIdResponse) + } + @Test fun ofAmendmentLedgerEntry() { val amendmentLedgerEntry = @@ -514,4 +909,90 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendmentLedgerEntry()) .contains(amendmentLedgerEntry) } + + @Test + fun ofAmendmentLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryByExternalIdResponse = + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofAmendmentLedgerEntry( + CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry + .EntryType + .AMENDMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryByExternalIdResponse) + .isEqualTo(customerCreditLedgerCreateEntryByExternalIdResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val customerCreditLedgerCreateEntryByExternalIdResponse = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + customerCreditLedgerCreateEntryByExternalIdResponse.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index a11a4159..c9c9cd39 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -2,10 +2,16 @@ 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 com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class CustomerCreditLedgerCreateEntryResponseTest { @@ -62,6 +68,62 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofIncrementLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryResponse = + CustomerCreditLedgerCreateEntryResponse.ofIncrementLedgerEntry( + CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.EntryType + .INCREMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryResponse) + .isEqualTo(customerCreditLedgerCreateEntryResponse) + } + @Test fun ofDecrementLedgerEntry() { val decrementLedgerEntry = @@ -100,6 +162,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() ) .startingBalance(0.0) + .eventId("event_id") + .invoiceId("invoice_id") + .priceId("price_id") .build() val customerCreditLedgerCreateEntryResponse = @@ -115,6 +180,65 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofDecrementLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryResponse = + CustomerCreditLedgerCreateEntryResponse.ofDecrementLedgerEntry( + CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.EntryType + .DECREMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .eventId("event_id") + .invoiceId("invoice_id") + .priceId("price_id") + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryResponse) + .isEqualTo(customerCreditLedgerCreateEntryResponse) + } + @Test fun ofExpirationChangeLedgerEntry() { val expirationChangeLedgerEntry = @@ -174,6 +298,66 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofExpirationChangeLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryResponse = + CustomerCreditLedgerCreateEntryResponse.ofExpirationChangeLedgerEntry( + CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry + .EntryType + .EXPIRATION_CHANGE + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .newBlockExpiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryResponse) + .isEqualTo(customerCreditLedgerCreateEntryResponse) + } + @Test fun ofCreditBlockExpiryLedgerEntry() { val creditBlockExpiryLedgerEntry = @@ -232,6 +416,67 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofCreditBlockExpiryLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryResponse = + CustomerCreditLedgerCreateEntryResponse.ofCreditBlockExpiryLedgerEntry( + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry + .EntryType + .CREDIT_BLOCK_EXPIRY + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryResponse) + .isEqualTo(customerCreditLedgerCreateEntryResponse) + } + @Test fun ofVoidLedgerEntry() { val voidLedgerEntry = @@ -283,6 +528,61 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofVoidLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryResponse = + CustomerCreditLedgerCreateEntryResponse.ofVoidLedgerEntry( + CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.EntryType.VOID + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .voidAmount(0.0) + .voidReason("void_reason") + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryResponse) + .isEqualTo(customerCreditLedgerCreateEntryResponse) + } + @Test fun ofVoidInitiatedLedgerEntry() { val voidInitiatedLedgerEntry = @@ -344,6 +644,65 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofVoidInitiatedLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryResponse = + CustomerCreditLedgerCreateEntryResponse.ofVoidInitiatedLedgerEntry( + CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.EntryType + .VOID_INITIATED + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .newBlockExpiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingBalance(0.0) + .voidAmount(0.0) + .voidReason("void_reason") + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryResponse) + .isEqualTo(customerCreditLedgerCreateEntryResponse) + } + @Test fun ofAmendmentLedgerEntry() { val amendmentLedgerEntry = @@ -396,4 +755,85 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()) .contains(amendmentLedgerEntry) } + + @Test + fun ofAmendmentLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerCreateEntryResponse = + CustomerCreditLedgerCreateEntryResponse.ofAmendmentLedgerEntry( + CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.EntryType + .AMENDMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerCreateEntryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerCreateEntryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerCreateEntryResponse) + .isEqualTo(customerCreditLedgerCreateEntryResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val customerCreditLedgerCreateEntryResponse = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + customerCreditLedgerCreateEntryResponse.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index ca70236d..6b221082 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -2,10 +2,16 @@ 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 com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class CustomerCreditLedgerListByExternalIdResponseTest { @@ -69,6 +75,64 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofIncrementLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListByExternalIdResponse = + CustomerCreditLedgerListByExternalIdResponse.ofIncrementLedgerEntry( + CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.EntryType + .INCREMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListByExternalIdResponse) + .isEqualTo(customerCreditLedgerListByExternalIdResponse) + } + @Test fun ofDecrementLedgerEntry() { val decrementLedgerEntry = @@ -110,6 +174,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() ) .startingBalance(0.0) + .eventId("event_id") + .invoiceId("invoice_id") + .priceId("price_id") .build() val customerCreditLedgerListByExternalIdResponse = @@ -129,6 +196,67 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofDecrementLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListByExternalIdResponse = + CustomerCreditLedgerListByExternalIdResponse.ofDecrementLedgerEntry( + CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.EntryType + .DECREMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .eventId("event_id") + .invoiceId("invoice_id") + .priceId("price_id") + .build() + ) + + val roundtrippedCustomerCreditLedgerListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListByExternalIdResponse) + .isEqualTo(customerCreditLedgerListByExternalIdResponse) + } + @Test fun ofExpirationChangeLedgerEntry() { val expirationChangeLedgerEntry = @@ -194,6 +322,68 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofExpirationChangeLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListByExternalIdResponse = + CustomerCreditLedgerListByExternalIdResponse.ofExpirationChangeLedgerEntry( + CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry + .EntryType + .EXPIRATION_CHANGE + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .newBlockExpiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListByExternalIdResponse) + .isEqualTo(customerCreditLedgerListByExternalIdResponse) + } + @Test fun ofCreditBlockExpiryLedgerEntry() { val creditBlockExpiryLedgerEntry = @@ -258,6 +448,67 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofCreditBlockExpiryLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListByExternalIdResponse = + CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiryLedgerEntry( + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry + .EntryType + .CREDIT_BLOCK_EXPIRY + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListByExternalIdResponse) + .isEqualTo(customerCreditLedgerListByExternalIdResponse) + } + @Test fun ofVoidLedgerEntry() { val voidLedgerEntry = @@ -315,6 +566,63 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofVoidLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListByExternalIdResponse = + CustomerCreditLedgerListByExternalIdResponse.ofVoidLedgerEntry( + CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.EntryType.VOID + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .voidAmount(0.0) + .voidReason("void_reason") + .build() + ) + + val roundtrippedCustomerCreditLedgerListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListByExternalIdResponse) + .isEqualTo(customerCreditLedgerListByExternalIdResponse) + } + @Test fun ofVoidInitiatedLedgerEntry() { val voidInitiatedLedgerEntry = @@ -380,6 +688,70 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofVoidInitiatedLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListByExternalIdResponse = + CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiatedLedgerEntry( + CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry + .Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry + .EntryType + .VOID_INITIATED + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .newBlockExpiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingBalance(0.0) + .voidAmount(0.0) + .voidReason("void_reason") + .build() + ) + + val roundtrippedCustomerCreditLedgerListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListByExternalIdResponse) + .isEqualTo(customerCreditLedgerListByExternalIdResponse) + } + @Test fun ofAmendmentLedgerEntry() { val amendmentLedgerEntry = @@ -439,4 +811,87 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()) .contains(amendmentLedgerEntry) } + + @Test + fun ofAmendmentLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListByExternalIdResponse = + CustomerCreditLedgerListByExternalIdResponse.ofAmendmentLedgerEntry( + CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry + .CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry + .EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.EntryType + .AMENDMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListByExternalIdResponse) + .isEqualTo(customerCreditLedgerListByExternalIdResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val customerCreditLedgerListByExternalIdResponse = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + customerCreditLedgerListByExternalIdResponse.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 4bc17f91..0e452a16 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -2,10 +2,16 @@ 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 com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class CustomerCreditLedgerListResponseTest { @@ -60,6 +66,57 @@ internal class CustomerCreditLedgerListResponseTest { assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofIncrementLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListResponse = + CustomerCreditLedgerListResponse.ofIncrementLedgerEntry( + CustomerCreditLedgerListResponse.IncrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListResponse.IncrementLedgerEntry.CreditBlock.builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListResponse.IncrementLedgerEntry.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryStatus.COMMITTED + ) + .entryType( + CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryType.INCREMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListResponse.IncrementLedgerEntry.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListResponse) + .isEqualTo(customerCreditLedgerListResponse) + } + @Test fun ofDecrementLedgerEntry() { val decrementLedgerEntry = @@ -96,6 +153,9 @@ internal class CustomerCreditLedgerListResponseTest { .build() ) .startingBalance(0.0) + .eventId("event_id") + .invoiceId("invoice_id") + .priceId("price_id") .build() val customerCreditLedgerListResponse = @@ -111,6 +171,60 @@ internal class CustomerCreditLedgerListResponseTest { assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofDecrementLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListResponse = + CustomerCreditLedgerListResponse.ofDecrementLedgerEntry( + CustomerCreditLedgerListResponse.DecrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListResponse.DecrementLedgerEntry.CreditBlock.builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListResponse.DecrementLedgerEntry.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListResponse.DecrementLedgerEntry.EntryStatus.COMMITTED + ) + .entryType( + CustomerCreditLedgerListResponse.DecrementLedgerEntry.EntryType.DECREMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListResponse.DecrementLedgerEntry.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .eventId("event_id") + .invoiceId("invoice_id") + .priceId("price_id") + .build() + ) + + val roundtrippedCustomerCreditLedgerListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListResponse) + .isEqualTo(customerCreditLedgerListResponse) + } + @Test fun ofExpirationChangeLedgerEntry() { val expirationChangeLedgerEntry = @@ -168,6 +282,63 @@ internal class CustomerCreditLedgerListResponseTest { assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofExpirationChangeLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListResponse = + CustomerCreditLedgerListResponse.ofExpirationChangeLedgerEntry( + CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.EntryType + .EXPIRATION_CHANGE + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .newBlockExpiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListResponse) + .isEqualTo(customerCreditLedgerListResponse) + } + @Test fun ofCreditBlockExpiryLedgerEntry() { val creditBlockExpiryLedgerEntry = @@ -224,6 +395,62 @@ internal class CustomerCreditLedgerListResponseTest { assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofCreditBlockExpiryLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListResponse = + CustomerCreditLedgerListResponse.ofCreditBlockExpiryLedgerEntry( + CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.Customer + .builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.EntryType + .CREDIT_BLOCK_EXPIRY + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListResponse) + .isEqualTo(customerCreditLedgerListResponse) + } + @Test fun ofVoidLedgerEntry() { val voidLedgerEntry = @@ -272,6 +499,57 @@ internal class CustomerCreditLedgerListResponseTest { assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofVoidLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListResponse = + CustomerCreditLedgerListResponse.ofVoidLedgerEntry( + CustomerCreditLedgerListResponse.VoidLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListResponse.VoidLedgerEntry.CreditBlock.builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListResponse.VoidLedgerEntry.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListResponse.VoidLedgerEntry.EntryStatus.COMMITTED + ) + .entryType(CustomerCreditLedgerListResponse.VoidLedgerEntry.EntryType.VOID) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListResponse.VoidLedgerEntry.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .voidAmount(0.0) + .voidReason("void_reason") + .build() + ) + + val roundtrippedCustomerCreditLedgerListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListResponse) + .isEqualTo(customerCreditLedgerListResponse) + } + @Test fun ofVoidInitiatedLedgerEntry() { val voidInitiatedLedgerEntry = @@ -327,6 +605,63 @@ internal class CustomerCreditLedgerListResponseTest { assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty } + @Test + fun ofVoidInitiatedLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListResponse = + CustomerCreditLedgerListResponse.ofVoidInitiatedLedgerEntry( + CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.CreditBlock + .builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.EntryStatus + .COMMITTED + ) + .entryType( + CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.EntryType + .VOID_INITIATED + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .newBlockExpiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingBalance(0.0) + .voidAmount(0.0) + .voidReason("void_reason") + .build() + ) + + val roundtrippedCustomerCreditLedgerListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListResponse) + .isEqualTo(customerCreditLedgerListResponse) + } + @Test fun ofAmendmentLedgerEntry() { val amendmentLedgerEntry = @@ -377,4 +712,75 @@ internal class CustomerCreditLedgerListResponseTest { assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()) .contains(amendmentLedgerEntry) } + + @Test + fun ofAmendmentLedgerEntryRoundtrip() { + val jsonMapper = jsonMapper() + val customerCreditLedgerListResponse = + CustomerCreditLedgerListResponse.ofAmendmentLedgerEntry( + CustomerCreditLedgerListResponse.AmendmentLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + CustomerCreditLedgerListResponse.AmendmentLedgerEntry.CreditBlock.builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerCreditLedgerListResponse.AmendmentLedgerEntry.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CustomerCreditLedgerListResponse.AmendmentLedgerEntry.EntryStatus.COMMITTED + ) + .entryType( + CustomerCreditLedgerListResponse.AmendmentLedgerEntry.EntryType.AMENDMENT + ) + .ledgerSequenceNumber(0L) + .metadata( + CustomerCreditLedgerListResponse.AmendmentLedgerEntry.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + + val roundtrippedCustomerCreditLedgerListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditLedgerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditLedgerListResponse) + .isEqualTo(customerCreditLedgerListResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val customerCreditLedgerListResponse = + jsonMapper() + .convertValue(testCase.value, jacksonTypeRef()) + + val e = + assertThrows { customerCreditLedgerListResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt index d49b1772..60171256 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -33,4 +35,28 @@ internal class CustomerCreditListByExternalIdResponseTest { assertThat(customerCreditListByExternalIdResponse.status()) .isEqualTo(CustomerCreditListByExternalIdResponse.Status.ACTIVE) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCreditListByExternalIdResponse = + CustomerCreditListByExternalIdResponse.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumInitialBalance(0.0) + .perUnitCostBasis("per_unit_cost_basis") + .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) + .build() + + val roundtrippedCustomerCreditListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditListByExternalIdResponse) + .isEqualTo(customerCreditListByExternalIdResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt index be0b17e0..99cf4253 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -32,4 +34,27 @@ internal class CustomerCreditListResponseTest { assertThat(customerCreditListResponse.status()) .isEqualTo(CustomerCreditListResponse.Status.ACTIVE) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCreditListResponse = + CustomerCreditListResponse.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumInitialBalance(0.0) + .perUnitCostBasis("per_unit_cost_basis") + .status(CustomerCreditListResponse.Status.ACTIVE) + .build() + + val roundtrippedCustomerCreditListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditListResponse).isEqualTo(customerCreditListResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponseTest.kt index 31ff42d7..890bcdb9 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -49,4 +51,38 @@ internal class CustomerCreditTopUpCreateByExternalIdResponseTest { assertThat(customerCreditTopUpCreateByExternalIdResponse.expiresAfterUnit()) .contains(CustomerCreditTopUpCreateByExternalIdResponse.ExpiresAfterUnit.DAY) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCreditTopUpCreateByExternalIdResponse = + CustomerCreditTopUpCreateByExternalIdResponse.builder() + .id("id") + .amount("amount") + .currency("currency") + .invoiceSettings( + CustomerCreditTopUpCreateByExternalIdResponse.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .expiresAfter(0L) + .expiresAfterUnit( + CustomerCreditTopUpCreateByExternalIdResponse.ExpiresAfterUnit.DAY + ) + .build() + + val roundtrippedCustomerCreditTopUpCreateByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditTopUpCreateByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditTopUpCreateByExternalIdResponse) + .isEqualTo(customerCreditTopUpCreateByExternalIdResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponseTest.kt index 6275850c..31455816 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -47,4 +49,36 @@ internal class CustomerCreditTopUpCreateResponseTest { assertThat(customerCreditTopUpCreateResponse.expiresAfterUnit()) .contains(CustomerCreditTopUpCreateResponse.ExpiresAfterUnit.DAY) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCreditTopUpCreateResponse = + CustomerCreditTopUpCreateResponse.builder() + .id("id") + .amount("amount") + .currency("currency") + .invoiceSettings( + CustomerCreditTopUpCreateResponse.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .expiresAfter(0L) + .expiresAfterUnit(CustomerCreditTopUpCreateResponse.ExpiresAfterUnit.DAY) + .build() + + val roundtrippedCustomerCreditTopUpCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditTopUpCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditTopUpCreateResponse) + .isEqualTo(customerCreditTopUpCreateResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponseTest.kt index 0f9103b9..00e12180 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -47,4 +49,36 @@ internal class CustomerCreditTopUpListByExternalIdResponseTest { assertThat(customerCreditTopUpListByExternalIdResponse.expiresAfterUnit()) .contains(CustomerCreditTopUpListByExternalIdResponse.ExpiresAfterUnit.DAY) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCreditTopUpListByExternalIdResponse = + CustomerCreditTopUpListByExternalIdResponse.builder() + .id("id") + .amount("amount") + .currency("currency") + .invoiceSettings( + CustomerCreditTopUpListByExternalIdResponse.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .expiresAfter(0L) + .expiresAfterUnit(CustomerCreditTopUpListByExternalIdResponse.ExpiresAfterUnit.DAY) + .build() + + val roundtrippedCustomerCreditTopUpListByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditTopUpListByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditTopUpListByExternalIdResponse) + .isEqualTo(customerCreditTopUpListByExternalIdResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponseTest.kt index 20f44759..b92446f7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -47,4 +49,36 @@ internal class CustomerCreditTopUpListResponseTest { assertThat(customerCreditTopUpListResponse.expiresAfterUnit()) .contains(CustomerCreditTopUpListResponse.ExpiresAfterUnit.DAY) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCreditTopUpListResponse = + CustomerCreditTopUpListResponse.builder() + .id("id") + .amount("amount") + .currency("currency") + .invoiceSettings( + CustomerCreditTopUpListResponse.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .expiresAfter(0L) + .expiresAfterUnit(CustomerCreditTopUpListResponse.ExpiresAfterUnit.DAY) + .build() + + val roundtrippedCustomerCreditTopUpListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreditTopUpListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreditTopUpListResponse) + .isEqualTo(customerCreditTopUpListResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt index 9275be14..19951acf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt @@ -2,7 +2,9 @@ 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 @@ -182,4 +184,101 @@ internal class CustomerTest { assertThat(customer.reportingConfiguration()) .contains(Customer.ReportingConfiguration.builder().exempt(true).build()) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customer = + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + + val roundtrippedCustomer = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customer), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomer).isEqualTo(customer) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupTest.kt index 1ca3999d..abc50fff 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupTest.kt @@ -2,7 +2,9 @@ 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 org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -38,4 +40,31 @@ internal class DimensionalPriceGroupTest { ) assertThat(dimensionalPriceGroup.name()).isEqualTo("name") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val dimensionalPriceGroup = + DimensionalPriceGroup.builder() + .id("id") + .billableMetricId("billable_metric_id") + .addDimension("region") + .addDimension("instance_type") + .externalDimensionalPriceGroupId("my_dimensional_price_group_id") + .metadata( + DimensionalPriceGroup.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .build() + + val roundtrippedDimensionalPriceGroup = + jsonMapper.readValue( + jsonMapper.writeValueAsString(dimensionalPriceGroup), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDimensionalPriceGroup).isEqualTo(dimensionalPriceGroup) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupsTest.kt index 21f74558..a2d6c619 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupsTest.kt @@ -2,7 +2,9 @@ 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 org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -51,4 +53,38 @@ internal class DimensionalPriceGroupsTest { assertThat(dimensionalPriceGroups.paginationMetadata()) .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val dimensionalPriceGroups = + DimensionalPriceGroups.builder() + .addData( + DimensionalPriceGroup.builder() + .id("id") + .billableMetricId("billable_metric_id") + .addDimension("region") + .addDimension("instance_type") + .externalDimensionalPriceGroupId("my_dimensional_price_group_id") + .metadata( + DimensionalPriceGroup.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedDimensionalPriceGroups = + jsonMapper.readValue( + jsonMapper.writeValueAsString(dimensionalPriceGroups), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDimensionalPriceGroups).isEqualTo(dimensionalPriceGroups) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/DiscountTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/DiscountTest.kt index 6818007b..8e49ea96 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/DiscountTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/DiscountTest.kt @@ -2,8 +2,15 @@ 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 com.withorb.api.errors.OrbInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class DiscountTest { @@ -15,6 +22,7 @@ internal class DiscountTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() val discount = Discount.ofPercentage(percentage) @@ -25,6 +33,29 @@ internal class DiscountTest { assertThat(discount.amount()).isEmpty } + @Test + fun ofPercentageRoundtrip() { + val jsonMapper = jsonMapper() + val discount = + Discount.ofPercentage( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + + val roundtrippedDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(discount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDiscount).isEqualTo(discount) + } + @Test fun ofTrial() { val trial = @@ -32,6 +63,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(TrialDiscount.DiscountType.TRIAL) + .reason("reason") + .trialAmountDiscount("trial_amount_discount") + .trialPercentageDiscount(0.0) .build() val discount = Discount.ofTrial(trial) @@ -42,6 +76,30 @@ internal class DiscountTest { assertThat(discount.amount()).isEmpty } + @Test + fun ofTrialRoundtrip() { + val jsonMapper = jsonMapper() + val discount = + Discount.ofTrial( + TrialDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(TrialDiscount.DiscountType.TRIAL) + .reason("reason") + .trialAmountDiscount("trial_amount_discount") + .trialPercentageDiscount(0.0) + .build() + ) + + val roundtrippedDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(discount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDiscount).isEqualTo(discount) + } + @Test fun ofUsage() { val usage = @@ -50,6 +108,7 @@ internal class DiscountTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(UsageDiscount.DiscountType.USAGE) .usageDiscount(0.0) + .reason("reason") .build() val discount = Discount.ofUsage(usage) @@ -60,6 +119,29 @@ internal class DiscountTest { assertThat(discount.amount()).isEmpty } + @Test + fun ofUsageRoundtrip() { + val jsonMapper = jsonMapper() + val discount = + Discount.ofUsage( + UsageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(0.0) + .reason("reason") + .build() + ) + + val roundtrippedDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(discount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDiscount).isEqualTo(discount) + } + @Test fun ofAmount() { val amount = @@ -68,6 +150,7 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(AmountDiscount.DiscountType.AMOUNT) + .reason("reason") .build() val discount = Discount.ofAmount(amount) @@ -77,4 +160,44 @@ internal class DiscountTest { assertThat(discount.usage()).isEmpty assertThat(discount.amount()).contains(amount) } + + @Test + fun ofAmountRoundtrip() { + val jsonMapper = jsonMapper() + val discount = + Discount.ofAmount( + AmountDiscount.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(AmountDiscount.DiscountType.AMOUNT) + .reason("reason") + .build() + ) + + val roundtrippedDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(discount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDiscount).isEqualTo(discount) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val discount = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { discount.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EvaluatePriceGroupTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EvaluatePriceGroupTest.kt index 37e4ff6d..ad128071 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EvaluatePriceGroupTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EvaluatePriceGroupTest.kt @@ -2,6 +2,8 @@ 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 @@ -21,4 +23,23 @@ internal class EvaluatePriceGroupTest { .containsExactly(EvaluatePriceGroup.GroupingValue.ofString("string")) assertThat(evaluatePriceGroup.quantity()).isEqualTo(0.0) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val evaluatePriceGroup = + EvaluatePriceGroup.builder() + .amount("amount") + .addGroupingValue("string") + .quantity(0.0) + .build() + + val roundtrippedEvaluatePriceGroup = + jsonMapper.readValue( + jsonMapper.writeValueAsString(evaluatePriceGroup), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEvaluatePriceGroup).isEqualTo(evaluatePriceGroup) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCloseResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCloseResponseTest.kt index 3d9b56f9..4eb3fc14 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCloseResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCloseResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -44,4 +46,31 @@ internal class EventBackfillCloseResponseTest { assertThat(eventBackfillCloseResponse.deprecationFilter()) .contains("my_numeric_property > 100 AND my_other_property = 'bar'") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventBackfillCloseResponse = + EventBackfillCloseResponse.builder() + .id("id") + .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerId("customer_id") + .eventsIngested(0L) + .replaceExistingEvents(true) + .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(EventBackfillCloseResponse.Status.PENDING) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") + .build() + + val roundtrippedEventBackfillCloseResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventBackfillCloseResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventBackfillCloseResponse).isEqualTo(eventBackfillCloseResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCreateResponseTest.kt index 9ec6fa80..4432729c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCreateResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -44,4 +46,31 @@ internal class EventBackfillCreateResponseTest { assertThat(eventBackfillCreateResponse.deprecationFilter()) .contains("my_numeric_property > 100 AND my_other_property = 'bar'") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventBackfillCreateResponse = + EventBackfillCreateResponse.builder() + .id("id") + .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerId("customer_id") + .eventsIngested(0L) + .replaceExistingEvents(true) + .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(EventBackfillCreateResponse.Status.PENDING) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") + .build() + + val roundtrippedEventBackfillCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventBackfillCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventBackfillCreateResponse).isEqualTo(eventBackfillCreateResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillFetchResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillFetchResponseTest.kt index 772a5c22..24bece3d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillFetchResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillFetchResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -44,4 +46,31 @@ internal class EventBackfillFetchResponseTest { assertThat(eventBackfillFetchResponse.deprecationFilter()) .contains("my_numeric_property > 100 AND my_other_property = 'bar'") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventBackfillFetchResponse = + EventBackfillFetchResponse.builder() + .id("id") + .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerId("customer_id") + .eventsIngested(0L) + .replaceExistingEvents(true) + .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(EventBackfillFetchResponse.Status.PENDING) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") + .build() + + val roundtrippedEventBackfillFetchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventBackfillFetchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventBackfillFetchResponse).isEqualTo(eventBackfillFetchResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillListResponseTest.kt index b374a7b6..11e6e8f5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillListResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -44,4 +46,31 @@ internal class EventBackfillListResponseTest { assertThat(eventBackfillListResponse.deprecationFilter()) .contains("my_numeric_property > 100 AND my_other_property = 'bar'") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventBackfillListResponse = + EventBackfillListResponse.builder() + .id("id") + .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerId("customer_id") + .eventsIngested(0L) + .replaceExistingEvents(true) + .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(EventBackfillListResponse.Status.PENDING) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") + .build() + + val roundtrippedEventBackfillListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventBackfillListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventBackfillListResponse).isEqualTo(eventBackfillListResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillRevertResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillRevertResponseTest.kt index 5bda6156..c1618afe 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillRevertResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillRevertResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -44,4 +46,31 @@ internal class EventBackfillRevertResponseTest { assertThat(eventBackfillRevertResponse.deprecationFilter()) .contains("my_numeric_property > 100 AND my_other_property = 'bar'") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventBackfillRevertResponse = + EventBackfillRevertResponse.builder() + .id("id") + .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerId("customer_id") + .eventsIngested(0L) + .replaceExistingEvents(true) + .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(EventBackfillRevertResponse.Status.PENDING) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") + .build() + + val roundtrippedEventBackfillRevertResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventBackfillRevertResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventBackfillRevertResponse).isEqualTo(eventBackfillRevertResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventDeprecateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventDeprecateResponseTest.kt index b09db579..ae012c33 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventDeprecateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventDeprecateResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -14,4 +16,19 @@ internal class EventDeprecateResponseTest { assertThat(eventDeprecateResponse.deprecated()).isEqualTo("deprecated") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventDeprecateResponse = + EventDeprecateResponse.builder().deprecated("deprecated").build() + + val roundtrippedEventDeprecateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventDeprecateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventDeprecateResponse).isEqualTo(eventDeprecateResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventIngestResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventIngestResponseTest.kt index 60b71375..bc3afa48 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventIngestResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventIngestResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -40,4 +42,32 @@ internal class EventIngestResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventIngestResponse = + EventIngestResponse.builder() + .addValidationFailed( + EventIngestResponse.ValidationFailed.builder() + .idempotencyKey("idempotency_key") + .addValidationError("string") + .build() + ) + .debug( + EventIngestResponse.Debug.builder() + .addDuplicate("string") + .addIngested("string") + .build() + ) + .build() + + val roundtrippedEventIngestResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventIngestResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventIngestResponse).isEqualTo(eventIngestResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventSearchResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventSearchResponseTest.kt index f5aa1d7a..c6c061ad 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventSearchResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventSearchResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -39,4 +41,31 @@ internal class EventSearchResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventSearchResponse = + EventSearchResponse.builder() + .addData( + EventSearchResponse.Data.builder() + .id("id") + .customerId("customer_id") + .deprecated(true) + .eventName("event_name") + .externalCustomerId("external_customer_id") + .properties(JsonValue.from(mapOf())) + .timestamp(OffsetDateTime.parse("2020-12-09T16:09:53Z")) + .build() + ) + .build() + + val roundtrippedEventSearchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventSearchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventSearchResponse).isEqualTo(eventSearchResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventUpdateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventUpdateResponseTest.kt index 89763016..8fd687db 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventUpdateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventUpdateResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -13,4 +15,18 @@ internal class EventUpdateResponseTest { assertThat(eventUpdateResponse.amended()).isEqualTo("amended") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventUpdateResponse = EventUpdateResponse.builder().amended("amended").build() + + val roundtrippedEventUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventUpdateResponse).isEqualTo(eventUpdateResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventVolumesTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventVolumesTest.kt index db689cb6..7a76a109 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventVolumesTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventVolumesTest.kt @@ -2,6 +2,8 @@ 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 @@ -30,4 +32,27 @@ internal class EventVolumesTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val eventVolumes = + EventVolumes.builder() + .addData( + EventVolumes.Data.builder() + .count(0L) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedEventVolumes = + jsonMapper.readValue( + jsonMapper.writeValueAsString(eventVolumes), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEventVolumes).isEqualTo(eventVolumes) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 69e1d2cc..d33b6b2a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -695,4 +697,349 @@ internal class InvoiceFetchUpcomingResponseTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(invoiceFetchUpcomingResponse.willAutoIssue()).isEqualTo(true) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invoiceFetchUpcomingResponse = + InvoiceFetchUpcomingResponse.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + InvoiceFetchUpcomingResponse.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( + InvoiceFetchUpcomingResponse.BillingAddress.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( + InvoiceFetchUpcomingResponse.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( + InvoiceFetchUpcomingResponse.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Invoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Type.INCREMENT + ) + .build() + ) + .customerTaxId( + InvoiceFetchUpcomingResponse.CustomerTaxId.builder() + .country(InvoiceFetchUpcomingResponse.CustomerTaxId.Country.AD) + .type(InvoiceFetchUpcomingResponse.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceNumber("JYEFHK-00001") + .invoicePdf("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + .invoiceSource(InvoiceFetchUpcomingResponse.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + InvoiceFetchUpcomingResponse.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + InvoiceFetchUpcomingResponse.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + InvoiceFetchUpcomingResponse.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + InvoiceFetchUpcomingResponse.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + InvoiceFetchUpcomingResponse.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + InvoiceFetchUpcomingResponse.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + InvoiceFetchUpcomingResponse.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + InvoiceFetchUpcomingResponse.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + InvoiceFetchUpcomingResponse.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + InvoiceFetchUpcomingResponse.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + InvoiceFetchUpcomingResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + InvoiceFetchUpcomingResponse.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + InvoiceFetchUpcomingResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceFetchUpcomingResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .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( + InvoiceFetchUpcomingResponse.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(InvoiceFetchUpcomingResponse.Status.ISSUED) + .subscription( + InvoiceFetchUpcomingResponse.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .targetDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + + val roundtrippedInvoiceFetchUpcomingResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invoiceFetchUpcomingResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvoiceFetchUpcomingResponse).isEqualTo(invoiceFetchUpcomingResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLevelDiscountTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLevelDiscountTest.kt index 3cf92f7f..e241a7ac 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLevelDiscountTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLevelDiscountTest.kt @@ -2,8 +2,15 @@ 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 com.withorb.api.errors.OrbInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class InvoiceLevelDiscountTest { @@ -15,6 +22,7 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() val invoiceLevelDiscount = InvoiceLevelDiscount.ofPercentage(percentage) @@ -24,6 +32,29 @@ internal class InvoiceLevelDiscountTest { assertThat(invoiceLevelDiscount.trial()).isEmpty } + @Test + fun ofPercentageRoundtrip() { + val jsonMapper = jsonMapper() + val invoiceLevelDiscount = + InvoiceLevelDiscount.ofPercentage( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + + val roundtrippedInvoiceLevelDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invoiceLevelDiscount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvoiceLevelDiscount).isEqualTo(invoiceLevelDiscount) + } + @Test fun ofAmount() { val amount = @@ -32,6 +63,7 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(AmountDiscount.DiscountType.AMOUNT) + .reason("reason") .build() val invoiceLevelDiscount = InvoiceLevelDiscount.ofAmount(amount) @@ -41,6 +73,29 @@ internal class InvoiceLevelDiscountTest { assertThat(invoiceLevelDiscount.trial()).isEmpty } + @Test + fun ofAmountRoundtrip() { + val jsonMapper = jsonMapper() + val invoiceLevelDiscount = + InvoiceLevelDiscount.ofAmount( + AmountDiscount.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(AmountDiscount.DiscountType.AMOUNT) + .reason("reason") + .build() + ) + + val roundtrippedInvoiceLevelDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invoiceLevelDiscount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvoiceLevelDiscount).isEqualTo(invoiceLevelDiscount) + } + @Test fun ofTrial() { val trial = @@ -48,6 +103,9 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(TrialDiscount.DiscountType.TRIAL) + .reason("reason") + .trialAmountDiscount("trial_amount_discount") + .trialPercentageDiscount(0.0) .build() val invoiceLevelDiscount = InvoiceLevelDiscount.ofTrial(trial) @@ -56,4 +114,46 @@ internal class InvoiceLevelDiscountTest { assertThat(invoiceLevelDiscount.amount()).isEmpty assertThat(invoiceLevelDiscount.trial()).contains(trial) } + + @Test + fun ofTrialRoundtrip() { + val jsonMapper = jsonMapper() + val invoiceLevelDiscount = + InvoiceLevelDiscount.ofTrial( + TrialDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(TrialDiscount.DiscountType.TRIAL) + .reason("reason") + .trialAmountDiscount("trial_amount_discount") + .trialPercentageDiscount(0.0) + .build() + ) + + val roundtrippedInvoiceLevelDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invoiceLevelDiscount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvoiceLevelDiscount).isEqualTo(invoiceLevelDiscount) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val invoiceLevelDiscount = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { invoiceLevelDiscount.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index bb8bda47..9e4c6a5c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -2,7 +2,9 @@ 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 kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -351,4 +353,179 @@ internal class InvoiceLineItemCreateResponseTest { assertThat(invoiceLineItemCreateResponse.usageCustomerIds().getOrNull()) .containsExactly("string") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invoiceLineItemCreateResponse = + InvoiceLineItemCreateResponse.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + InvoiceLineItemCreateResponse.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + InvoiceLineItemCreateResponse.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Type.MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + InvoiceLineItemCreateResponse.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + + val roundtrippedInvoiceLineItemCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invoiceLineItemCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvoiceLineItemCreateResponse) + .isEqualTo(invoiceLineItemCreateResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 44b7b6dc..7cd2f569 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -2,7 +2,9 @@ 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 @@ -639,4 +641,318 @@ internal class InvoiceTest { assertThat(invoice.voidedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(invoice.willAutoIssue()).isEqualTo(true) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invoice = + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.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( + Invoice.BillingAddress.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( + Invoice.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( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action(Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder().id("id").build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .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(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type(Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type.MATRIX) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .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( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription(Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build()) + .subtotal("8.00") + .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 roundtrippedInvoice = + jsonMapper.readValue(jsonMapper.writeValueAsString(invoice), jacksonTypeRef()) + + assertThat(roundtrippedInvoice).isEqualTo(invoice) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt index 44c0ca15..4e483568 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt @@ -2,6 +2,8 @@ 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 @@ -36,4 +38,28 @@ internal class ItemTest { ) assertThat(item.name()).isEqualTo("name") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val item = + Item.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExternalConnection( + Item.ExternalConnection.builder() + .externalConnectionName( + Item.ExternalConnection.ExternalConnectionName.STRIPE + ) + .externalEntityId("external_entity_id") + .build() + ) + .name("name") + .build() + + val roundtrippedItem = + jsonMapper.readValue(jsonMapper.writeValueAsString(item), jacksonTypeRef()) + + assertThat(roundtrippedItem).isEqualTo(item) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PaginationMetadataTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PaginationMetadataTest.kt index 3fb4362e..ab4f100f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PaginationMetadataTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PaginationMetadataTest.kt @@ -2,6 +2,8 @@ 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 @@ -15,4 +17,19 @@ internal class PaginationMetadataTest { assertThat(paginationMetadata.hasMore()).isEqualTo(true) assertThat(paginationMetadata.nextCursor()).contains("next_cursor") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val paginationMetadata = + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + + val roundtrippedPaginationMetadata = + jsonMapper.readValue( + jsonMapper.writeValueAsString(paginationMetadata), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPaginationMetadata).isEqualTo(paginationMetadata) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountTest.kt index 798afbd1..520a7f91 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountTest.kt @@ -2,6 +2,8 @@ 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 @@ -25,4 +27,25 @@ internal class PercentageDiscountTest { assertThat(percentageDiscount.percentageDiscount()).isEqualTo(0.15) assertThat(percentageDiscount.reason()).contains("reason") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val percentageDiscount = + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + + val roundtrippedPercentageDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(percentageDiscount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPercentageDiscount).isEqualTo(percentageDiscount) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 28d02850..75426179 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -2,7 +2,9 @@ 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 kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -399,4 +401,200 @@ internal class PlanTest { ) assertThat(plan.version()).isEqualTo(0L) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val plan = + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + + val roundtrippedPlan = + jsonMapper.readValue(jsonMapper.writeValueAsString(plan), jacksonTypeRef()) + + assertThat(roundtrippedPlan).isEqualTo(plan) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateResponseTest.kt index e2182d45..86afe973 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -29,4 +31,27 @@ internal class PriceEvaluateResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val priceEvaluateResponse = + PriceEvaluateResponse.builder() + .addData( + EvaluatePriceGroup.builder() + .amount("amount") + .addGroupingValue("string") + .quantity(0.0) + .build() + ) + .build() + + val roundtrippedPriceEvaluateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(priceEvaluateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPriceEvaluateResponse).isEqualTo(priceEvaluateResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 67c7b583..3d2e7872 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -2,10 +2,16 @@ 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 com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class PriceTest { @@ -37,6 +43,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -72,6 +79,12 @@ internal class PriceTest { .planPhaseOrder(0L) .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .unitConfig(Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build()) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofUnit(unit) @@ -106,6 +119,93 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofUnitRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofUnit( + Price.UnitPrice.builder() + .id("id") + .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofPackagePrice() { val packagePrice = @@ -134,6 +234,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -176,6 +277,12 @@ internal class PriceTest { ) .planPhaseOrder(0L) .priceType(Price.PackagePrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.PackagePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofPackagePrice(packagePrice) @@ -210,6 +317,96 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofPackagePriceRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofPackagePrice( + Price.PackagePrice.builder() + .id("id") + .billableMetric(Price.PackagePrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.PackagePrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.PackagePrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.PackagePrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.PackagePrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.PackagePrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.PackagePrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.PackagePrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.PackagePrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.PackagePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.PackagePrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.PackagePrice.ModelType.PACKAGE) + .name("name") + .packageConfig( + Price.PackagePrice.PackageConfig.builder() + .packageAmount("package_amount") + .packageSize(0L) + .build() + ) + .planPhaseOrder(0L) + .priceType(Price.PackagePrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.PackagePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofMatrix() { val matrix = @@ -238,6 +435,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -286,6 +484,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.MatrixPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.MatrixPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofMatrix(matrix) @@ -320,6 +524,102 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofMatrixRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofMatrix( + Price.MatrixPrice.builder() + .id("id") + .billableMetric(Price.MatrixPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.MatrixPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.MatrixPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.MatrixPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.MatrixPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.MatrixPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.MatrixPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.MatrixPrice.Item.builder().id("id").name("name").build()) + .matrixConfig( + Price.MatrixPrice.MatrixConfig.builder() + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + Price.MatrixPrice.MatrixConfig.MatrixValue.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .build() + ) + .maximum( + Price.MatrixPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.MatrixPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.MatrixPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.MatrixPrice.ModelType.MATRIX) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.MatrixPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.MatrixPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofTiered() { val tiered = @@ -348,6 +648,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -390,10 +691,17 @@ internal class PriceTest { Price.TieredPrice.TieredConfig.Tier.builder() .firstUnit(0.0) .unitAmount("unit_amount") + .lastUnit(0.0) .build() ) .build() ) + .dimensionalPriceConfiguration( + Price.TieredPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofTiered(tiered) @@ -428,6 +736,101 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofTieredRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofTiered( + Price.TieredPrice.builder() + .id("id") + .billableMetric(Price.TieredPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.TieredPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.TieredPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.TieredPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.TieredPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.TieredPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.TieredPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.TieredPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.TieredPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.TieredPrice.ModelType.TIERED) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.TieredPrice.PriceType.USAGE_PRICE) + .tieredConfig( + Price.TieredPrice.TieredConfig.builder() + .addTier( + Price.TieredPrice.TieredConfig.Tier.builder() + .firstUnit(0.0) + .unitAmount("unit_amount") + .lastUnit(0.0) + .build() + ) + .build() + ) + .dimensionalPriceConfiguration( + Price.TieredPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofTieredBps() { val tieredBps = @@ -458,6 +861,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -500,10 +904,18 @@ internal class PriceTest { Price.TieredBpsPrice.TieredBpsConfig.Tier.builder() .bps(0.0) .minimumAmount("minimum_amount") + .maximumAmount("maximum_amount") + .perUnitMaximum("per_unit_maximum") .build() ) .build() ) + .dimensionalPriceConfiguration( + Price.TieredBpsPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofTieredBps(tieredBps) @@ -538,6 +950,102 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofTieredBpsRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofTieredBps( + Price.TieredBpsPrice.builder() + .id("id") + .billableMetric(Price.TieredBpsPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.TieredBpsPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredBpsPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.TieredBpsPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.TieredBpsPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.TieredBpsPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredBpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.TieredBpsPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.TieredBpsPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.TieredBpsPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.TieredBpsPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.TieredBpsPrice.ModelType.TIERED_BPS) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.TieredBpsPrice.PriceType.USAGE_PRICE) + .tieredBpsConfig( + Price.TieredBpsPrice.TieredBpsConfig.builder() + .addTier( + Price.TieredBpsPrice.TieredBpsConfig.Tier.builder() + .bps(0.0) + .minimumAmount("minimum_amount") + .maximumAmount("maximum_amount") + .perUnitMaximum("per_unit_maximum") + .build() + ) + .build() + ) + .dimensionalPriceConfiguration( + Price.TieredBpsPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofBps() { val bps = @@ -550,7 +1058,12 @@ internal class PriceTest { .durationUnit(Price.BpsPrice.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bpsConfig(Price.BpsPrice.BpsConfig.builder().bps(0.0).build()) + .bpsConfig( + Price.BpsPrice.BpsConfig.builder() + .bps(0.0) + .perUnitMaximum("per_unit_maximum") + .build() + ) .cadence(Price.BpsPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -567,6 +1080,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -601,6 +1115,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.BpsPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.BpsPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofBps(bps) @@ -635,6 +1155,94 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofBpsRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofBps( + Price.BpsPrice.builder() + .id("id") + .billableMetric(Price.BpsPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.BpsPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(Price.BpsPrice.BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .bpsConfig( + Price.BpsPrice.BpsConfig.builder() + .bps(0.0) + .perUnitMaximum("per_unit_maximum") + .build() + ) + .cadence(Price.BpsPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.BpsPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.BpsPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.BpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.BpsPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.BpsPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.BpsPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.BpsPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.BpsPrice.ModelType.BPS) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.BpsPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.BpsPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofBulkBps() { val bulkBps = @@ -649,7 +1257,13 @@ internal class PriceTest { ) .bulkBpsConfig( Price.BulkBpsPrice.BulkBpsConfig.builder() - .addTier(Price.BulkBpsPrice.BulkBpsConfig.Tier.builder().bps(0.0).build()) + .addTier( + Price.BulkBpsPrice.BulkBpsConfig.Tier.builder() + .bps(0.0) + .maximumAmount("maximum_amount") + .perUnitMaximum("per_unit_maximum") + .build() + ) .build() ) .cadence(Price.BulkBpsPrice.Cadence.ONE_TIME) @@ -668,6 +1282,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -704,6 +1319,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.BulkBpsPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.BulkBpsPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofBulkBps(bulkBps) @@ -738,6 +1359,101 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofBulkBpsRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofBulkBps( + Price.BulkBpsPrice.builder() + .id("id") + .billableMetric(Price.BulkBpsPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.BulkBpsPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.BulkBpsPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .bulkBpsConfig( + Price.BulkBpsPrice.BulkBpsConfig.builder() + .addTier( + Price.BulkBpsPrice.BulkBpsConfig.Tier.builder() + .bps(0.0) + .maximumAmount("maximum_amount") + .perUnitMaximum("per_unit_maximum") + .build() + ) + .build() + ) + .cadence(Price.BulkBpsPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.BulkBpsPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.BulkBpsPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.BulkBpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.BulkBpsPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.BulkBpsPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.BulkBpsPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.BulkBpsPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.BulkBpsPrice.ModelType.BULK_BPS) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.BulkBpsPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.BulkBpsPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofBulk() { val bulk = @@ -755,6 +1471,7 @@ internal class PriceTest { .addTier( Price.BulkPrice.BulkConfig.Tier.builder() .unitAmount("unit_amount") + .maximumUnits(0.0) .build() ) .build() @@ -775,6 +1492,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -809,6 +1527,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.BulkPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.BulkPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofBulk(bulk) @@ -843,6 +1567,100 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofBulkRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofBulk( + Price.BulkPrice.builder() + .id("id") + .billableMetric(Price.BulkPrice.BillableMetric.builder().id("id").build()) + .billingCycleConfiguration( + Price.BulkPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.BulkPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .bulkConfig( + Price.BulkPrice.BulkConfig.builder() + .addTier( + Price.BulkPrice.BulkConfig.Tier.builder() + .unitAmount("unit_amount") + .maximumUnits(0.0) + .build() + ) + .build() + ) + .cadence(Price.BulkPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.BulkPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.BulkPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.BulkPrice.InvoicingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .item(Price.BulkPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.BulkPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.BulkPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.BulkPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.BulkPrice.ModelType.BULK) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.BulkPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.BulkPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofThresholdTotalAmount() { val thresholdTotalAmount = @@ -876,6 +1694,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -918,6 +1737,12 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.ThresholdTotalAmountPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) @@ -952,6 +1777,103 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofThresholdTotalAmountRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofThresholdTotalAmount( + Price.ThresholdTotalAmountPrice.builder() + .id("id") + .billableMetric( + Price.ThresholdTotalAmountPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.ThresholdTotalAmountPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.ThresholdTotalAmountPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.ThresholdTotalAmountPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.ThresholdTotalAmountPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.ThresholdTotalAmountPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.ThresholdTotalAmountPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.ThresholdTotalAmountPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.ThresholdTotalAmountPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.ThresholdTotalAmountPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.ThresholdTotalAmountPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.ThresholdTotalAmountPrice.ModelType.THRESHOLD_TOTAL_AMOUNT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.ThresholdTotalAmountPrice.PriceType.USAGE_PRICE) + .thresholdTotalAmountConfig( + Price.ThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.ThresholdTotalAmountPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofTieredPackage() { val tieredPackage = @@ -982,6 +1904,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1023,6 +1946,12 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.TieredPackagePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofTieredPackage(tieredPackage) @@ -1057,6 +1986,98 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofTieredPackageRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofTieredPackage( + Price.TieredPackagePrice.builder() + .id("id") + .billableMetric( + Price.TieredPackagePrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.TieredPackagePrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredPackagePrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.TieredPackagePrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.TieredPackagePrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.TieredPackagePrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredPackagePrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.TieredPackagePrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.TieredPackagePrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.TieredPackagePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.TieredPackagePrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.TieredPackagePrice.ModelType.TIERED_PACKAGE) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.TieredPackagePrice.PriceType.USAGE_PRICE) + .tieredPackageConfig( + Price.TieredPackagePrice.TieredPackageConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.TieredPackagePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofGroupedTiered() { val groupedTiered = @@ -1087,6 +2108,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1128,6 +2150,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.GroupedTieredPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedTieredPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofGroupedTiered(groupedTiered) @@ -1162,6 +2190,98 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofGroupedTieredRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofGroupedTiered( + Price.GroupedTieredPrice.builder() + .id("id") + .billableMetric( + Price.GroupedTieredPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.GroupedTieredPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedTieredPrice.BillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .cadence(Price.GroupedTieredPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.GroupedTieredPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .groupedTieredConfig( + Price.GroupedTieredPrice.GroupedTieredConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .invoicingCycleConfiguration( + Price.GroupedTieredPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedTieredPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.GroupedTieredPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.GroupedTieredPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.GroupedTieredPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.GroupedTieredPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.GroupedTieredPrice.ModelType.GROUPED_TIERED) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.GroupedTieredPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedTieredPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofTieredWithMinimum() { val tieredWithMinimum = @@ -1194,6 +2314,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1236,6 +2357,12 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.TieredWithMinimumPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofTieredWithMinimum(tieredWithMinimum) @@ -1270,6 +2397,100 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofTieredWithMinimumRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofTieredWithMinimum( + Price.TieredWithMinimumPrice.builder() + .id("id") + .billableMetric( + Price.TieredWithMinimumPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.TieredWithMinimumPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredWithMinimumPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.TieredWithMinimumPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.TieredWithMinimumPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.TieredWithMinimumPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredWithMinimumPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item(Price.TieredWithMinimumPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.TieredWithMinimumPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.TieredWithMinimumPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.TieredWithMinimumPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.TieredWithMinimumPrice.ModelType.TIERED_WITH_MINIMUM) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.TieredWithMinimumPrice.PriceType.USAGE_PRICE) + .tieredWithMinimumConfig( + Price.TieredWithMinimumPrice.TieredWithMinimumConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.TieredWithMinimumPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofTieredPackageWithMinimum() { val tieredPackageWithMinimum = @@ -1304,6 +2525,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1351,6 +2573,12 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.TieredPackageWithMinimumPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) @@ -1385,6 +2613,110 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofTieredPackageWithMinimumRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofTieredPackageWithMinimum( + Price.TieredPackageWithMinimumPrice.builder() + .id("id") + .billableMetric( + Price.TieredPackageWithMinimumPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.TieredPackageWithMinimumPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredPackageWithMinimumPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.TieredPackageWithMinimumPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.TieredPackageWithMinimumPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.TieredPackageWithMinimumPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredPackageWithMinimumPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.TieredPackageWithMinimumPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.TieredPackageWithMinimumPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.TieredPackageWithMinimumPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.TieredPackageWithMinimumPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType( + Price.TieredPackageWithMinimumPrice.ModelType.TIERED_PACKAGE_WITH_MINIMUM + ) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.TieredPackageWithMinimumPrice.PriceType.USAGE_PRICE) + .tieredPackageWithMinimumConfig( + Price.TieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.TieredPackageWithMinimumPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofPackageWithAllocation() { val packageWithAllocation = @@ -1418,6 +2750,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1461,6 +2794,12 @@ internal class PriceTest { ) .planPhaseOrder(0L) .priceType(Price.PackageWithAllocationPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.PackageWithAllocationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofPackageWithAllocation(packageWithAllocation) @@ -1495,6 +2834,106 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofPackageWithAllocationRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofPackageWithAllocation( + Price.PackageWithAllocationPrice.builder() + .id("id") + .billableMetric( + Price.PackageWithAllocationPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.PackageWithAllocationPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.PackageWithAllocationPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.PackageWithAllocationPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.PackageWithAllocationPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.PackageWithAllocationPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.PackageWithAllocationPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.PackageWithAllocationPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.PackageWithAllocationPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.PackageWithAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.PackageWithAllocationPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.PackageWithAllocationPrice.ModelType.PACKAGE_WITH_ALLOCATION) + .name("name") + .packageWithAllocationConfig( + Price.PackageWithAllocationPrice.PackageWithAllocationConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .planPhaseOrder(0L) + .priceType(Price.PackageWithAllocationPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.PackageWithAllocationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofUnitWithPercent() { val unitWithPercent = @@ -1527,6 +2966,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1568,6 +3008,12 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.UnitWithPercentPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofUnitWithPercent(unitWithPercent) @@ -1602,6 +3048,99 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofUnitWithPercentRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofUnitWithPercent( + Price.UnitWithPercentPrice.builder() + .id("id") + .billableMetric( + Price.UnitWithPercentPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitWithPercentPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitWithPercentPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitWithPercentPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitWithPercentPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitWithPercentPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitWithPercentPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitWithPercentPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitWithPercentPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitWithPercentPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitWithPercentPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitWithPercentPrice.ModelType.UNIT_WITH_PERCENT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitWithPercentPrice.PriceType.USAGE_PRICE) + .unitWithPercentConfig( + Price.UnitWithPercentPrice.UnitWithPercentConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitWithPercentPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofMatrixWithAllocation() { val matrixWithAllocation = @@ -1635,6 +3174,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1686,6 +3226,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.MatrixWithAllocationPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.MatrixWithAllocationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofMatrixWithAllocation(matrixWithAllocation) @@ -1720,6 +3266,113 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofMatrixWithAllocationRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofMatrixWithAllocation( + Price.MatrixWithAllocationPrice.builder() + .id("id") + .billableMetric( + Price.MatrixWithAllocationPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.MatrixWithAllocationPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.MatrixWithAllocationPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.MatrixWithAllocationPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.MatrixWithAllocationPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.MatrixWithAllocationPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.MatrixWithAllocationPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.MatrixWithAllocationPrice.Item.builder().id("id").name("name").build() + ) + .matrixWithAllocationConfig( + Price.MatrixWithAllocationPrice.MatrixWithAllocationConfig.builder() + .allocation(0.0) + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + Price.MatrixWithAllocationPrice.MatrixWithAllocationConfig + .MatrixValue + .builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .build() + ) + .maximum( + Price.MatrixWithAllocationPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.MatrixWithAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.MatrixWithAllocationPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.MatrixWithAllocationPrice.ModelType.MATRIX_WITH_ALLOCATION) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.MatrixWithAllocationPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.MatrixWithAllocationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofTieredWithProration() { val tieredWithProration = @@ -1753,6 +3406,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1795,6 +3449,12 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.TieredWithProrationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofTieredWithProration(tieredWithProration) @@ -1829,6 +3489,103 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofTieredWithProrationRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofTieredWithProration( + Price.TieredWithProrationPrice.builder() + .id("id") + .billableMetric( + Price.TieredWithProrationPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.TieredWithProrationPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredWithProrationPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.TieredWithProrationPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.TieredWithProrationPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.TieredWithProrationPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.TieredWithProrationPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.TieredWithProrationPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.TieredWithProrationPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.TieredWithProrationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.TieredWithProrationPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.TieredWithProrationPrice.ModelType.TIERED_WITH_PRORATION) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.TieredWithProrationPrice.PriceType.USAGE_PRICE) + .tieredWithProrationConfig( + Price.TieredWithProrationPrice.TieredWithProrationConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.TieredWithProrationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofUnitWithProration() { val unitWithProration = @@ -1861,6 +3618,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -1903,6 +3661,12 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.UnitWithProrationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofUnitWithProration(unitWithProration) @@ -1937,6 +3701,100 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofUnitWithProrationRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofUnitWithProration( + Price.UnitWithProrationPrice.builder() + .id("id") + .billableMetric( + Price.UnitWithProrationPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitWithProrationPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitWithProrationPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitWithProrationPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitWithProrationPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitWithProrationPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitWithProrationPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitWithProrationPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitWithProrationPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitWithProrationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitWithProrationPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitWithProrationPrice.ModelType.UNIT_WITH_PRORATION) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitWithProrationPrice.PriceType.USAGE_PRICE) + .unitWithProrationConfig( + Price.UnitWithProrationPrice.UnitWithProrationConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitWithProrationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofGroupedAllocation() { val groupedAllocation = @@ -1969,6 +3827,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2011,6 +3870,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.GroupedAllocationPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedAllocationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofGroupedAllocation(groupedAllocation) @@ -2045,6 +3910,100 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofGroupedAllocationRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofGroupedAllocation( + Price.GroupedAllocationPrice.builder() + .id("id") + .billableMetric( + Price.GroupedAllocationPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.GroupedAllocationPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedAllocationPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.GroupedAllocationPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.GroupedAllocationPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .groupedAllocationConfig( + Price.GroupedAllocationPrice.GroupedAllocationConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .invoicingCycleConfiguration( + Price.GroupedAllocationPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedAllocationPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item(Price.GroupedAllocationPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.GroupedAllocationPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.GroupedAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.GroupedAllocationPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.GroupedAllocationPrice.ModelType.GROUPED_ALLOCATION) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.GroupedAllocationPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedAllocationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofGroupedWithProratedMinimum() { val groupedWithProratedMinimum = @@ -2079,6 +4038,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2129,6 +4089,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.GroupedWithProratedMinimumPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedWithProratedMinimumPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) @@ -2163,6 +4129,113 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofGroupedWithProratedMinimumRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofGroupedWithProratedMinimum( + Price.GroupedWithProratedMinimumPrice.builder() + .id("id") + .billableMetric( + Price.GroupedWithProratedMinimumPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.GroupedWithProratedMinimumPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedWithProratedMinimumPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.GroupedWithProratedMinimumPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.GroupedWithProratedMinimumPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .groupedWithProratedMinimumConfig( + Price.GroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .invoicingCycleConfiguration( + Price.GroupedWithProratedMinimumPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedWithProratedMinimumPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.GroupedWithProratedMinimumPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.GroupedWithProratedMinimumPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.GroupedWithProratedMinimumPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.GroupedWithProratedMinimumPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType( + Price.GroupedWithProratedMinimumPrice.ModelType + .GROUPED_WITH_PRORATED_MINIMUM + ) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.GroupedWithProratedMinimumPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedWithProratedMinimumPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofGroupedWithMeteredMinimum() { val groupedWithMeteredMinimum = @@ -2197,6 +4270,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2247,6 +4321,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.GroupedWithMeteredMinimumPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedWithMeteredMinimumPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) @@ -2281,6 +4361,111 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofGroupedWithMeteredMinimumRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofGroupedWithMeteredMinimum( + Price.GroupedWithMeteredMinimumPrice.builder() + .id("id") + .billableMetric( + Price.GroupedWithMeteredMinimumPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.GroupedWithMeteredMinimumPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedWithMeteredMinimumPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.GroupedWithMeteredMinimumPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.GroupedWithMeteredMinimumPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .groupedWithMeteredMinimumConfig( + Price.GroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .invoicingCycleConfiguration( + Price.GroupedWithMeteredMinimumPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedWithMeteredMinimumPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.GroupedWithMeteredMinimumPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.GroupedWithMeteredMinimumPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.GroupedWithMeteredMinimumPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.GroupedWithMeteredMinimumPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType( + Price.GroupedWithMeteredMinimumPrice.ModelType.GROUPED_WITH_METERED_MINIMUM + ) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.GroupedWithMeteredMinimumPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedWithMeteredMinimumPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofMatrixWithDisplayName() { val matrixWithDisplayName = @@ -2314,6 +4499,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2357,6 +4543,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.MatrixWithDisplayNamePrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.MatrixWithDisplayNamePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) @@ -2391,6 +4583,106 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofMatrixWithDisplayNameRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofMatrixWithDisplayName( + Price.MatrixWithDisplayNamePrice.builder() + .id("id") + .billableMetric( + Price.MatrixWithDisplayNamePrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.MatrixWithDisplayNamePrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.MatrixWithDisplayNamePrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.MatrixWithDisplayNamePrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.MatrixWithDisplayNamePrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.MatrixWithDisplayNamePrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.MatrixWithDisplayNamePrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.MatrixWithDisplayNamePrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .matrixWithDisplayNameConfig( + Price.MatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .maximum( + Price.MatrixWithDisplayNamePrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.MatrixWithDisplayNamePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.MatrixWithDisplayNamePrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.MatrixWithDisplayNamePrice.ModelType.MATRIX_WITH_DISPLAY_NAME) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.MatrixWithDisplayNamePrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.MatrixWithDisplayNamePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofBulkWithProration() { val bulkWithProration = @@ -2428,6 +4720,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2465,6 +4758,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.BulkWithProrationPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.BulkWithProrationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofBulkWithProration(bulkWithProration) @@ -2499,6 +4798,100 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofBulkWithProrationRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofBulkWithProration( + Price.BulkWithProrationPrice.builder() + .id("id") + .billableMetric( + Price.BulkWithProrationPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.BulkWithProrationPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.BulkWithProrationPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .bulkWithProrationConfig( + Price.BulkWithProrationPrice.BulkWithProrationConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .cadence(Price.BulkWithProrationPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.BulkWithProrationPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.BulkWithProrationPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.BulkWithProrationPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item(Price.BulkWithProrationPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.BulkWithProrationPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.BulkWithProrationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.BulkWithProrationPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.BulkWithProrationPrice.ModelType.BULK_WITH_PRORATION) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.BulkWithProrationPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.BulkWithProrationPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofGroupedTieredPackage() { val groupedTieredPackage = @@ -2532,6 +4925,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2574,6 +4968,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.GroupedTieredPackagePrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedTieredPackagePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofGroupedTieredPackage(groupedTieredPackage) @@ -2608,6 +5008,103 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofGroupedTieredPackageRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofGroupedTieredPackage( + Price.GroupedTieredPackagePrice.builder() + .id("id") + .billableMetric( + Price.GroupedTieredPackagePrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.GroupedTieredPackagePrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedTieredPackagePrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.GroupedTieredPackagePrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.GroupedTieredPackagePrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .groupedTieredPackageConfig( + Price.GroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .invoicingCycleConfiguration( + Price.GroupedTieredPackagePrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.GroupedTieredPackagePrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.GroupedTieredPackagePrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.GroupedTieredPackagePrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.GroupedTieredPackagePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.GroupedTieredPackagePrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.GroupedTieredPackagePrice.ModelType.GROUPED_TIERED_PACKAGE) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.GroupedTieredPackagePrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.GroupedTieredPackagePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofMaxGroupTieredPackage() { val maxGroupTieredPackage = @@ -2641,6 +5138,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2684,6 +5182,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.MaxGroupTieredPackagePrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.MaxGroupTieredPackagePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) @@ -2718,6 +5222,106 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofMaxGroupTieredPackageRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofMaxGroupTieredPackage( + Price.MaxGroupTieredPackagePrice.builder() + .id("id") + .billableMetric( + Price.MaxGroupTieredPackagePrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.MaxGroupTieredPackagePrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.MaxGroupTieredPackagePrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.MaxGroupTieredPackagePrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.MaxGroupTieredPackagePrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.MaxGroupTieredPackagePrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.MaxGroupTieredPackagePrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.MaxGroupTieredPackagePrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maxGroupTieredPackageConfig( + Price.MaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .maximum( + Price.MaxGroupTieredPackagePrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.MaxGroupTieredPackagePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.MaxGroupTieredPackagePrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.MaxGroupTieredPackagePrice.ModelType.MAX_GROUP_TIERED_PACKAGE) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.MaxGroupTieredPackagePrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.MaxGroupTieredPackagePrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofScalableMatrixWithUnitPricing() { val scalableMatrixWithUnitPricing = @@ -2754,6 +5358,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2806,6 +5411,12 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.ScalableMatrixWithUnitPricingPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) @@ -2840,6 +5451,114 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofScalableMatrixWithUnitPricingRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofScalableMatrixWithUnitPricing( + Price.ScalableMatrixWithUnitPricingPrice.builder() + .id("id") + .billableMetric( + Price.ScalableMatrixWithUnitPricingPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.ScalableMatrixWithUnitPricingPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.ScalableMatrixWithUnitPricingPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.ScalableMatrixWithUnitPricingPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.ScalableMatrixWithUnitPricingPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.ScalableMatrixWithUnitPricingPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.ScalableMatrixWithUnitPricingPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.ScalableMatrixWithUnitPricingPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.ScalableMatrixWithUnitPricingPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.ScalableMatrixWithUnitPricingPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.ScalableMatrixWithUnitPricingPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType( + Price.ScalableMatrixWithUnitPricingPrice.ModelType + .SCALABLE_MATRIX_WITH_UNIT_PRICING + ) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.ScalableMatrixWithUnitPricingPrice.PriceType.USAGE_PRICE) + .scalableMatrixWithUnitPricingConfig( + Price.ScalableMatrixWithUnitPricingPrice.ScalableMatrixWithUnitPricingConfig + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.ScalableMatrixWithUnitPricingPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofScalableMatrixWithTieredPricing() { val scalableMatrixWithTieredPricing = @@ -2876,6 +5595,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -2928,6 +5648,13 @@ internal class PriceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .dimensionalPriceConfiguration( + Price.ScalableMatrixWithTieredPricingPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) @@ -2963,6 +5690,117 @@ internal class PriceTest { assertThat(price.cumulativeGroupedBulk()).isEmpty } + @Test + fun ofScalableMatrixWithTieredPricingRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofScalableMatrixWithTieredPricing( + Price.ScalableMatrixWithTieredPricingPrice.builder() + .id("id") + .billableMetric( + Price.ScalableMatrixWithTieredPricingPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.ScalableMatrixWithTieredPricingPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.ScalableMatrixWithTieredPricingPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.ScalableMatrixWithTieredPricingPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.ScalableMatrixWithTieredPricingPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.ScalableMatrixWithTieredPricingPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.ScalableMatrixWithTieredPricingPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.ScalableMatrixWithTieredPricingPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.ScalableMatrixWithTieredPricingPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.ScalableMatrixWithTieredPricingPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.ScalableMatrixWithTieredPricingPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType( + Price.ScalableMatrixWithTieredPricingPrice.ModelType + .SCALABLE_MATRIX_WITH_TIERED_PRICING + ) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.ScalableMatrixWithTieredPricingPrice.PriceType.USAGE_PRICE) + .scalableMatrixWithTieredPricingConfig( + Price.ScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .dimensionalPriceConfiguration( + Price.ScalableMatrixWithTieredPricingPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofCumulativeGroupedBulk() { val cumulativeGroupedBulk = @@ -3001,6 +5839,7 @@ internal class PriceTest { .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .discountType(PercentageDiscount.DiscountType.PERCENTAGE) .percentageDiscount(0.15) + .reason("reason") .build() ) .externalPriceId("external_price_id") @@ -3039,6 +5878,12 @@ internal class PriceTest { .name("name") .planPhaseOrder(0L) .priceType(Price.CumulativeGroupedBulkPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.CumulativeGroupedBulkPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) .build() val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) @@ -3072,4 +5917,121 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).contains(cumulativeGroupedBulk) } + + @Test + fun ofCumulativeGroupedBulkRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofCumulativeGroupedBulk( + Price.CumulativeGroupedBulkPrice.builder() + .id("id") + .billableMetric( + Price.CumulativeGroupedBulkPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.CumulativeGroupedBulkPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.CumulativeGroupedBulkPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.CumulativeGroupedBulkPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.CumulativeGroupedBulkPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .cumulativeGroupedBulkConfig( + Price.CumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.CumulativeGroupedBulkPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.CumulativeGroupedBulkPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.CumulativeGroupedBulkPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.CumulativeGroupedBulkPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.CumulativeGroupedBulkPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.CumulativeGroupedBulkPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.CumulativeGroupedBulkPrice.ModelType.CUMULATIVE_GROUPED_BULK) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.CumulativeGroupedBulkPrice.PriceType.USAGE_PRICE) + .dimensionalPriceConfiguration( + Price.CumulativeGroupedBulkPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val price = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { price.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt index 4be87550..3aa43326 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1003,4 +1005,508 @@ internal class SubscriptionCancelResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionCancelResponse = + SubscriptionCancelResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionCancelResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionCancelResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionCancelResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionCancelResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionCancelResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionCancelResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionCancelResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionCancelResponse.PriceInterval.FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionCancelResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionCancelResponse.Status.ACTIVE) + .trialInfo( + SubscriptionCancelResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionCancelResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionCancelResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionCancelResponse).isEqualTo(subscriptionCancelResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt index 19d915a0..18c18c41 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1003,4 +1005,508 @@ internal class SubscriptionCreateResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionCreateResponse = + SubscriptionCreateResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionCreateResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionCreateResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionCreateResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionCreateResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionCreateResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionCreateResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionCreateResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionCreateResponse.PriceInterval.FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionCreateResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionCreateResponse.Status.ACTIVE) + .trialInfo( + SubscriptionCreateResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionCreateResponse).isEqualTo(subscriptionCreateResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index d9464a4e..1197b4f4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -235,4 +237,135 @@ internal class SubscriptionFetchCostsResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionFetchCostsResponse = + SubscriptionFetchCostsResponse.builder() + .addData( + SubscriptionFetchCostsResponse.Data.builder() + .addPerPriceCost( + SubscriptionFetchCostsResponse.Data.PerPriceCost.builder() + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .priceId("price_id") + .subtotal("subtotal") + .total("total") + .quantity(0.0) + .build() + ) + .subtotal("subtotal") + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("total") + .build() + ) + .build() + + val roundtrippedSubscriptionFetchCostsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionFetchCostsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionFetchCostsResponse) + .isEqualTo(subscriptionFetchCostsResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponseTest.kt index fcea875f..614c7a38 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -39,4 +41,31 @@ internal class SubscriptionFetchScheduleResponseTest { assertThat(subscriptionFetchScheduleResponse.startDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionFetchScheduleResponse = + SubscriptionFetchScheduleResponse.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .plan( + SubscriptionFetchScheduleResponse.Plan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSubscriptionFetchScheduleResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionFetchScheduleResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionFetchScheduleResponse) + .isEqualTo(subscriptionFetchScheduleResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt index 86c75271..b0fbfbd6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1010,4 +1012,512 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionPriceIntervalsResponse = + SubscriptionPriceIntervalsResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionPriceIntervalsResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionPriceIntervalsResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionPriceIntervalsResponse.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionPriceIntervalsResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionPriceIntervalsResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionPriceIntervalsResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionPriceIntervalsResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionPriceIntervalsResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionPriceIntervalsResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionPriceIntervalsResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionPriceIntervalsResponse.Status.ACTIVE) + .trialInfo( + SubscriptionPriceIntervalsResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionPriceIntervalsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionPriceIntervalsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionPriceIntervalsResponse) + .isEqualTo(subscriptionPriceIntervalsResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt index f4d16621..8782ad26 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1012,4 +1014,513 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionSchedulePlanChangeResponse = + SubscriptionSchedulePlanChangeResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionSchedulePlanChangeResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionSchedulePlanChangeResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionSchedulePlanChangeResponse.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionSchedulePlanChangeResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionSchedulePlanChangeResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionSchedulePlanChangeResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionSchedulePlanChangeResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionSchedulePlanChangeResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionSchedulePlanChangeResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionSchedulePlanChangeResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionSchedulePlanChangeResponse.Status.ACTIVE) + .trialInfo( + SubscriptionSchedulePlanChangeResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionSchedulePlanChangeResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionSchedulePlanChangeResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionSchedulePlanChangeResponse) + .isEqualTo(subscriptionSchedulePlanChangeResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 412fb9f6..e457c341 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -2,7 +2,9 @@ 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 @@ -995,4 +997,505 @@ internal class SubscriptionTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscription = + Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + Subscription.AdjustmentInterval.builder() + .id("id") + .adjustment( + Subscription.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Subscription.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + Subscription.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + Subscription.DiscountInterval.AmountDiscountInterval.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + Subscription.DiscountInterval.AmountDiscountInterval.DiscountType.AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + Subscription.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + Subscription.PriceInterval.FixedFeeQuantityTransition.builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(Subscription.Status.ACTIVE) + .trialInfo( + Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscription = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscription), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscription).isEqualTo(subscription) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt index d6a16ac3..ae7fab59 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1008,4 +1010,511 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionTriggerPhaseResponse = + SubscriptionTriggerPhaseResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionTriggerPhaseResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionTriggerPhaseResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionTriggerPhaseResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionTriggerPhaseResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionTriggerPhaseResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionTriggerPhaseResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionTriggerPhaseResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionTriggerPhaseResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionTriggerPhaseResponse.Status.ACTIVE) + .trialInfo( + SubscriptionTriggerPhaseResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionTriggerPhaseResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionTriggerPhaseResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionTriggerPhaseResponse) + .isEqualTo(subscriptionTriggerPhaseResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt index a496b73e..0d02f5ee 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1016,4 +1018,515 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUnscheduleCancellationResponse = + SubscriptionUnscheduleCancellationResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUnscheduleCancellationResponse.BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionUnscheduleCancellationResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionUnscheduleCancellationResponse.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionUnscheduleCancellationResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionUnscheduleCancellationResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionUnscheduleCancellationResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionUnscheduleCancellationResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionUnscheduleCancellationResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionUnscheduleCancellationResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionUnscheduleCancellationResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionUnscheduleCancellationResponse.Status.ACTIVE) + .trialInfo( + SubscriptionUnscheduleCancellationResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionUnscheduleCancellationResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionUnscheduleCancellationResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionUnscheduleCancellationResponse) + .isEqualTo(subscriptionUnscheduleCancellationResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt index c8bf43e1..48efd8b3 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1037,4 +1039,522 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUnscheduleFixedFeeQuantityUpdatesResponse = + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.Status.ACTIVE) + .trialInfo( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionUnscheduleFixedFeeQuantityUpdatesResponse) + .isEqualTo(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt index fbc9aa79..f86b193e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1024,4 +1026,518 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUnschedulePendingPlanChangesResponse = + SubscriptionUnschedulePendingPlanChangesResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUnschedulePendingPlanChangesResponse + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUnschedulePendingPlanChangesResponse.BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionUnschedulePendingPlanChangesResponse.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionUnschedulePendingPlanChangesResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionUnschedulePendingPlanChangesResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionUnschedulePendingPlanChangesResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionUnschedulePendingPlanChangesResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionUnschedulePendingPlanChangesResponse.Status.ACTIVE) + .trialInfo( + SubscriptionUnschedulePendingPlanChangesResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionUnschedulePendingPlanChangesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionUnschedulePendingPlanChangesResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionUnschedulePendingPlanChangesResponse) + .isEqualTo(subscriptionUnschedulePendingPlanChangesResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt index 798ade22..137ea292 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1016,4 +1018,515 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUpdateFixedFeeQuantityResponse = + SubscriptionUpdateFixedFeeQuantityResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUpdateFixedFeeQuantityResponse.BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionUpdateFixedFeeQuantityResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionUpdateFixedFeeQuantityResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionUpdateFixedFeeQuantityResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionUpdateFixedFeeQuantityResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionUpdateFixedFeeQuantityResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionUpdateFixedFeeQuantityResponse.Status.ACTIVE) + .trialInfo( + SubscriptionUpdateFixedFeeQuantityResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionUpdateFixedFeeQuantityResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionUpdateFixedFeeQuantityResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionUpdateFixedFeeQuantityResponse) + .isEqualTo(subscriptionUpdateFixedFeeQuantityResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt index 5da28dc8..76204150 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt @@ -2,7 +2,9 @@ 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 @@ -1007,4 +1009,510 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUpdateTrialResponse = + SubscriptionUpdateTrialResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUpdateTrialResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUpdateTrialResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionUpdateTrialResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionUpdateTrialResponse.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionUpdateTrialResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionUpdateTrialResponse.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionUpdateTrialResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionUpdateTrialResponse.PriceInterval.FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionUpdateTrialResponse.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionUpdateTrialResponse.Status.ACTIVE) + .trialInfo( + SubscriptionUpdateTrialResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedSubscriptionUpdateTrialResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionUpdateTrialResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionUpdateTrialResponse) + .isEqualTo(subscriptionUpdateTrialResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUsageTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUsageTest.kt index 5fd9c20e..f032ca2c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUsageTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUsageTest.kt @@ -2,9 +2,16 @@ 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 com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class SubscriptionUsageTest { @@ -41,6 +48,47 @@ internal class SubscriptionUsageTest { assertThat(subscriptionUsage.grouped()).isEmpty } + @Test + fun ofUngroupedRoundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUsage = + SubscriptionUsage.ofUngrouped( + SubscriptionUsage.UngroupedSubscriptionUsage.builder() + .addData( + SubscriptionUsage.UngroupedSubscriptionUsage.Data.builder() + .billableMetric( + SubscriptionUsage.UngroupedSubscriptionUsage.Data.BillableMetric + .builder() + .id("id") + .name("name") + .build() + ) + .addUsage( + SubscriptionUsage.UngroupedSubscriptionUsage.Data.Usage.builder() + .quantity(0.0) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .viewMode( + SubscriptionUsage.UngroupedSubscriptionUsage.Data.ViewMode.PERIODIC + ) + .build() + ) + .build() + ) + + val roundtrippedSubscriptionUsage = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionUsage), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionUsage).isEqualTo(subscriptionUsage) + } + @Test fun ofGrouped() { val grouped = @@ -69,6 +117,9 @@ internal class SubscriptionUsageTest { .viewMode(SubscriptionUsage.GroupedSubscriptionUsage.Data.ViewMode.PERIODIC) .build() ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) .build() val subscriptionUsage = SubscriptionUsage.ofGrouped(grouped) @@ -76,4 +127,73 @@ internal class SubscriptionUsageTest { assertThat(subscriptionUsage.ungrouped()).isEmpty assertThat(subscriptionUsage.grouped()).contains(grouped) } + + @Test + fun ofGroupedRoundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUsage = + SubscriptionUsage.ofGrouped( + SubscriptionUsage.GroupedSubscriptionUsage.builder() + .addData( + SubscriptionUsage.GroupedSubscriptionUsage.Data.builder() + .billableMetric( + SubscriptionUsage.GroupedSubscriptionUsage.Data.BillableMetric + .builder() + .id("id") + .name("name") + .build() + ) + .metricGroup( + SubscriptionUsage.GroupedSubscriptionUsage.Data.MetricGroup + .builder() + .propertyKey("property_key") + .propertyValue("property_value") + .build() + ) + .addUsage( + SubscriptionUsage.GroupedSubscriptionUsage.Data.Usage.builder() + .quantity(0.0) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .viewMode( + SubscriptionUsage.GroupedSubscriptionUsage.Data.ViewMode.PERIODIC + ) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + ) + + val roundtrippedSubscriptionUsage = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionUsage), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionUsage).isEqualTo(subscriptionUsage) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val subscriptionUsage = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { subscriptionUsage.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 9a05394e..556cfe64 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -2,7 +2,9 @@ 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 @@ -1061,4 +1063,556 @@ internal class SubscriptionsTest { assertThat(subscriptions.paginationMetadata()) .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptions = + Subscriptions.builder() + .addData( + Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + Subscription.AdjustmentInterval.builder() + .id("id") + .adjustment( + Subscription.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Subscription.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + Subscription.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + Subscription.DiscountInterval.AmountDiscountInterval.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + Subscription.DiscountInterval.AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + Subscription.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + Subscription.PriceInterval.FixedFeeQuantityTransition.builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(Subscription.Status.ACTIVE) + .trialInfo( + Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedSubscriptions = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptions), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptions).isEqualTo(subscriptions) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/TopLevelPingResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TopLevelPingResponseTest.kt index 79490913..7c8f0389 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/TopLevelPingResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/TopLevelPingResponseTest.kt @@ -2,6 +2,8 @@ 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 @@ -13,4 +15,18 @@ internal class TopLevelPingResponseTest { assertThat(topLevelPingResponse.response()).isEqualTo("response") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val topLevelPingResponse = TopLevelPingResponse.builder().response("response").build() + + val roundtrippedTopLevelPingResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(topLevelPingResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTopLevelPingResponse).isEqualTo(topLevelPingResponse) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/TrialDiscountTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TrialDiscountTest.kt index fa3a9593..d3c98067 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/TrialDiscountTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/TrialDiscountTest.kt @@ -2,6 +2,8 @@ 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 @@ -26,4 +28,26 @@ internal class TrialDiscountTest { assertThat(trialDiscount.trialAmountDiscount()).contains("trial_amount_discount") assertThat(trialDiscount.trialPercentageDiscount()).contains(0.0) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val trialDiscount = + TrialDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(TrialDiscount.DiscountType.TRIAL) + .reason("reason") + .trialAmountDiscount("trial_amount_discount") + .trialPercentageDiscount(0.0) + .build() + + val roundtrippedTrialDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(trialDiscount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTrialDiscount).isEqualTo(trialDiscount) + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageDiscountTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageDiscountTest.kt index 00f45919..214d316f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageDiscountTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageDiscountTest.kt @@ -2,6 +2,8 @@ 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 @@ -24,4 +26,25 @@ internal class UsageDiscountTest { assertThat(usageDiscount.usageDiscount()).isEqualTo(0.0) assertThat(usageDiscount.reason()).contains("reason") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val usageDiscount = + UsageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(0.0) + .reason("reason") + .build() + + val roundtrippedUsageDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(usageDiscount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUsageDiscount).isEqualTo(usageDiscount) + } }