diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fed4b17f..97976d55 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.52.0" + ".": "0.52.1" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 2262920e..037b2232 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-36a6db97756e8658369c9af3c0ac532ecacb032e5b8f6211094dcb4052943ff3.yml -openapi_spec_hash: 26886fa8e59fa3674320897e3409e540 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-95a3d7780935a38e0cf076d4ad2d68bd1a5641bced8398d972db2e92751d364a.yml +openapi_spec_hash: 9ebe818c4ad4f2d9c4e473b5192d7544 config_hash: ec4f1e02d3528e3a93a73e33bca17c2a diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b64a4d3..a4720984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.52.1 (2025-03-31) + +Full Changelog: [v0.52.0...v0.52.1](https://github.com/orbcorp/orb-java/compare/v0.52.0...v0.52.1) + +### Bug Fixes + +* **client:** limit json deserialization coercion ([#373](https://github.com/orbcorp/orb-java/issues/373)) ([654e81c](https://github.com/orbcorp/orb-java/commit/654e81cf520631050936ae5cf9397c0e4a9cf02b)) + + +### Chores + +* **internal:** codegen related update ([#371](https://github.com/orbcorp/orb-java/issues/371)) ([28dbf0a](https://github.com/orbcorp/orb-java/commit/28dbf0a107b892656275633f3805eb2d3c7f93fa)) + ## 0.52.0 (2025-03-26) Full Changelog: [v0.51.0...v0.52.0](https://github.com/orbcorp/orb-java/compare/v0.51.0...v0.52.0) diff --git a/README.md b/README.md index 69c6aa50..ba9c139a 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.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.52.1) @@ -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.0") +implementation("com.withorb.api:orb-java:0.52.1") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:0.52.0") com.withorb.api orb-java - 0.52.0 + 0.52.1 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 3434d43f..3a242454 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ allprojects { group = "com.withorb.api" - version = "0.52.0" // x-release-please-version + version = "0.52.1" // x-release-please-version } diff --git a/orb-java-core/build.gradle.kts b/orb-java-core/build.gradle.kts index a0bbeafb..8a8d05d5 100644 --- a/orb-java-core/build.gradle.kts +++ b/orb-java-core/build.gradle.kts @@ -34,6 +34,7 @@ dependencies { testImplementation("org.assertj:assertj-core:3.25.3") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") testImplementation("org.mockito:mockito-core:5.14.2") testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") 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 4fc63b4d..2a73d238 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 @@ -11,6 +11,7 @@ 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) : @@ -29,6 +30,13 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T + protected fun ObjectCodec.deserialize(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, 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 26311c69..8710064b 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 @@ -8,8 +8,11 @@ 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.json.JsonMapper import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.type.LogicalType import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.kotlinModule @@ -21,6 +24,60 @@ fun jsonMapper(): JsonMapper = .addModule(Jdk8Module()) .addModule(JavaTimeModule()) .addModule(SimpleModule().addSerializer(InputStreamJsonSerializer)) + .withCoercionConfig(LogicalType.Boolean) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Integer) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Float) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Textual) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Array) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Collection) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Map) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.POJO) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + } .serializationInclusion(JsonInclude.Include.NON_ABSENT) .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) 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 a93fa471..a2c4dac0 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 @@ -563,16 +563,16 @@ private constructor( when (discountType) { "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Discount(percentage = it, _json = json) - } + return Discount( + percentage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Discount(amount = it, _json = json) - } + return Discount( + amount = deserialize(node, jacksonTypeRef()), + _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 984ef4f4..19d1b3b2 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 @@ -875,20 +875,18 @@ private constructor( when (discountType) { "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Discount(newCouponPercentage = it, _json = json) - } + return Discount( + newCouponPercentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Discount(newCouponAmount = it, _json = json) - } + return Discount( + newCouponAmount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 695b6d9b..794d1fb7 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 @@ -4016,20 +4016,17 @@ private constructor( when (taxProvider) { "avalara" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newAvalara = it, _json = json) - } + return TaxConfiguration( + newAvalara = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "taxjar" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newTaxJar = it, _json = json) - } + return TaxConfiguration( + newTaxJar = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 da41ea92..16b0054d 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 @@ -724,74 +724,56 @@ private constructor( when (entryType) { "increment" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addIncrementCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addIncrementCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "decrement" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addDecrementCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addDecrementCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "expiration_change" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addExpirationChangeCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addExpirationChangeCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef< + AddExpirationChangeCreditLedgerEntryRequestParams + >(), + ), + _json = json, + ) } "void" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addVoidCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addVoidCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amendment" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addAmendmentCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addAmendmentCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } 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 07466b18..d724db6f 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 @@ -302,73 +302,52 @@ private constructor( when (entryType) { "increment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - incrementLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryByExternalIdResponse( + incrementLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "decrement" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - decrementLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryByExternalIdResponse( + decrementLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "expiration_change" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryByExternalIdResponse( + expirationChangeLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "credit_block_expiry" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryByExternalIdResponse( + creditBlockExpiryLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "void" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryByExternalIdResponse( + voidLedgerEntry = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "void_initiated" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryByExternalIdResponse( + voidInitiatedLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amendment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - amendmentLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryByExternalIdResponse( + amendmentLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 4e7639db..9f9f60b6 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 @@ -719,74 +719,56 @@ private constructor( when (entryType) { "increment" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addIncrementCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addIncrementCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "decrement" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addDecrementCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addDecrementCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "expiration_change" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addExpirationChangeCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addExpirationChangeCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef< + AddExpirationChangeCreditLedgerEntryRequestParams + >(), + ), + _json = json, + ) } "void" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addVoidCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addVoidCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amendment" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addAmendmentCreditLedgerEntryRequestParams = it, - _json = json, - ) - } + return Body( + addAmendmentCreditLedgerEntryRequestParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } 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 3f3a60da..cb660d53 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 @@ -291,73 +291,52 @@ private constructor( when (entryType) { "increment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - incrementLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryResponse( + incrementLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "decrement" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - decrementLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryResponse( + decrementLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "expiration_change" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryResponse( + expirationChangeLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "credit_block_expiry" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryResponse( + creditBlockExpiryLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "void" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - voidLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryResponse( + voidLedgerEntry = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "void_initiated" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryResponse( + voidInitiatedLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amendment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - amendmentLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerCreateEntryResponse( + amendmentLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 3d4acc56..b30e0a89 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 @@ -300,73 +300,52 @@ private constructor( when (entryType) { "increment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - incrementLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListByExternalIdResponse( + incrementLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "decrement" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - decrementLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListByExternalIdResponse( + decrementLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "expiration_change" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListByExternalIdResponse( + expirationChangeLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "credit_block_expiry" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListByExternalIdResponse( + creditBlockExpiryLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "void" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - voidLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListByExternalIdResponse( + voidLedgerEntry = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "void_initiated" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListByExternalIdResponse( + voidInitiatedLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amendment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - amendmentLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListByExternalIdResponse( + amendmentLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 beb252ff..81c15399 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 @@ -286,73 +286,52 @@ private constructor( when (entryType) { "increment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListResponse( - incrementLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListResponse( + incrementLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "decrement" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListResponse( - decrementLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListResponse( + decrementLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "expiration_change" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListResponse( + expirationChangeLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "credit_block_expiry" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListResponse( + creditBlockExpiryLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "void" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListResponse( - voidLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListResponse( + voidLedgerEntry = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "void_initiated" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListResponse( + voidInitiatedLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amendment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListResponse( - amendmentLedgerEntry = it, - _json = json, - ) - } + return CustomerCreditLedgerListResponse( + amendmentLedgerEntry = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 adb32522..914eead0 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 @@ -3947,20 +3947,17 @@ private constructor( when (taxProvider) { "avalara" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newAvalara = it, _json = json) - } + return TaxConfiguration( + newAvalara = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "taxjar" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newTaxJar = it, _json = json) - } + return TaxConfiguration( + newTaxJar = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 af6fcfbe..9f7b8181 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 @@ -3943,20 +3943,17 @@ private constructor( when (taxProvider) { "avalara" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newAvalara = it, _json = json) - } + return TaxConfiguration( + newAvalara = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "taxjar" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newTaxJar = it, _json = json) - } + return TaxConfiguration( + newTaxJar = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 1d7faf7b..109c0639 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 @@ -160,28 +160,28 @@ private constructor( when (discountType) { "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Discount(percentage = it, _json = json) - } + return Discount( + percentage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "trial" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Discount(trial = it, _json = json) - } + return Discount( + trial = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Discount(usage = it, _json = json) - } + return Discount( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Discount(amount = it, _json = json) - } + return Discount( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 2e62f035..dfbe313d 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 @@ -7435,53 +7435,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryUsageDiscount = it, _json = json) - } + return Adjustment( + monetaryUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryAmountDiscount = it, _json = json) - } + return Adjustment( + monetaryAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryPercentageDiscount = it, _json = json) - } + return Adjustment( + monetaryPercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMinimum = it, _json = json) - } + return Adjustment( + monetaryMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMaximum = it, _json = json) - } + return Adjustment( + monetaryMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -10803,28 +10798,22 @@ private constructor( when (type) { "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(matrix = it, _json = json) - } + return SubLineItem( + matrix = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tier" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(tier = it, _json = json) - } + return SubLineItem( + tier = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "'null'" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(other = it, _json = json) - } + return SubLineItem( + other = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 0cdcbd06..bc5ee923 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 @@ -7426,53 +7426,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryUsageDiscount = it, _json = json) - } + return Adjustment( + monetaryUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryAmountDiscount = it, _json = json) - } + return Adjustment( + monetaryAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryPercentageDiscount = it, _json = json) - } + return Adjustment( + monetaryPercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMinimum = it, _json = json) - } + return Adjustment( + monetaryMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMaximum = it, _json = json) - } + return Adjustment( + monetaryMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -10794,28 +10789,22 @@ private constructor( when (type) { "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(matrix = it, _json = json) - } + return SubLineItem( + matrix = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tier" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(tier = it, _json = json) - } + return SubLineItem( + tier = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "'null'" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(other = it, _json = json) - } + return SubLineItem( + other = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 023e08f8..76dbc4c4 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 @@ -149,22 +149,22 @@ private constructor( when (discountType) { "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InvoiceLevelDiscount(percentage = it, _json = json) - } + return InvoiceLevelDiscount( + percentage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InvoiceLevelDiscount(amount = it, _json = json) - } + return InvoiceLevelDiscount( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "trial" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InvoiceLevelDiscount(trial = it, _json = json) - } + return InvoiceLevelDiscount( + trial = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 ce4874b9..56b2e6df 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 @@ -1526,47 +1526,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryUsageDiscount = it, _json = json) - } + return Adjustment( + monetaryUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryAmountDiscount = it, _json = json) - } + return Adjustment( + monetaryAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryPercentageDiscount = it, _json = json) - } + return Adjustment( + monetaryPercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMinimum = it, _json = json) - } + return Adjustment( + monetaryMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMaximum = it, _json = json) - } + return Adjustment( + monetaryMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -4837,22 +4838,22 @@ private constructor( when (type) { "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return SubLineItem(matrix = it, _json = json) - } + return SubLineItem( + matrix = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tier" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return SubLineItem(tier = it, _json = json) - } + return SubLineItem( + tier = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "'null'" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return SubLineItem(other = it, _json = json) - } + return SubLineItem( + other = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 1abbdd01..f8a41c0a 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 @@ -1536,47 +1536,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhasePercentageDiscount = it, _json = json) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 12e1fd4b..4a3a3455 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 @@ -2003,212 +2003,204 @@ private constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(newPlanUnit = it, _json = json) - } + return Price( + newPlanUnit = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanPackage = it, _json = json) - } + return Price( + newPlanPackage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(newPlanMatrix = it, _json = json) - } + return Price( + newPlanMatrix = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(newPlanTiered = it, _json = json) - } + return Price( + newPlanTiered = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanTieredBps = it, _json = json) - } + return Price( + newPlanTieredBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(newPlanBps = it, _json = json) - } + return Price( + newPlanBps = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanBulkBps = it, _json = json) - } + return Price( + newPlanBulkBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(newPlanBulk = it, _json = json) - } + return Price( + newPlanBulk = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "threshold_total_amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanThresholdTotalAmount = it, _json = json) - } + return Price( + newPlanThresholdTotalAmount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanTieredPackage = it, _json = json) - } + return Price( + newPlanTieredPackage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_with_minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanTieredWithMinimum = it, _json = json) - } + return Price( + newPlanTieredWithMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "unit_with_percent" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanUnitWithPercent = it, _json = json) - } + return Price( + newPlanUnitWithPercent = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package_with_allocation" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanPackageWithAllocation = it, _json = json) - } + return Price( + newPlanPackageWithAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanTierWithProration = it, _json = json) - } + return Price( + newPlanTierWithProration = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "unit_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanUnitWithProration = it, _json = json) - } + return Price( + newPlanUnitWithProration = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_allocation" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanGroupedAllocation = it, _json = json) - } + return Price( + newPlanGroupedAllocation = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newPlanGroupedWithProratedMinimum = it, _json = json) - } + return Price( + newPlanGroupedWithProratedMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newPlanGroupedWithMeteredMinimum = it, _json = json) - } + return Price( + newPlanGroupedWithMeteredMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "matrix_with_display_name" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanMatrixWithDisplayName = it, _json = json) - } + return Price( + newPlanMatrixWithDisplayName = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bulk_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanBulkWithProration = it, _json = json) - } + return Price( + newPlanBulkWithProration = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanGroupedTieredPackage = it, _json = json) - } + return Price( + newPlanGroupedTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "max_group_tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanMaxGroupTieredPackage = it, _json = json) - } + return Price( + newPlanMaxGroupTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newPlanScalableMatrixWithUnitPricing = it, - _json = json, - ) - } + return Price( + newPlanScalableMatrixWithUnitPricing = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newPlanScalableMatrixWithTieredPricing = it, - _json = json, - ) - } + return Price( + newPlanScalableMatrixWithTieredPricing = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "cumulative_grouped_bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newPlanCumulativeGroupedBulk = it, _json = json) - } + return Price( + newPlanCumulativeGroupedBulk = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } 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 6483bd22..e1d5c45a 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 @@ -719,198 +719,189 @@ private constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(unit = it, _json = json) - } + return Price( + unit = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(packagePrice = it, _json = json) - } + return Price( + packagePrice = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(matrix = it, _json = json) - } + return Price( + matrix = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(tiered = it, _json = json) - } + return Price( + tiered = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(tieredBps = it, _json = json) - } + return Price( + tieredBps = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(bps = it, _json = json) - } + return Price(bps = deserialize(node, jacksonTypeRef()), _json = json) } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(bulkBps = it, _json = json) - } + return Price( + bulkBps = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(bulk = it, _json = json) - } + return Price( + bulk = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "threshold_total_amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(thresholdTotalAmount = it, _json = json) - } + return Price( + thresholdTotalAmount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(tieredPackage = it, _json = json) - } + return Price( + tieredPackage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(groupedTiered = it, _json = json) - } + return Price( + groupedTiered = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_with_minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(tieredWithMinimum = it, _json = json) - } + return Price( + tieredWithMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_package_with_minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(tieredPackageWithMinimum = it, _json = json) - } + return Price( + tieredPackageWithMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package_with_allocation" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(packageWithAllocation = it, _json = json) - } + return Price( + packageWithAllocation = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "unit_with_percent" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(unitWithPercent = it, _json = json) - } + return Price( + unitWithPercent = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "matrix_with_allocation" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(matrixWithAllocation = it, _json = json) - } + return Price( + matrixWithAllocation = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(tieredWithProration = it, _json = json) - } + return Price( + tieredWithProration = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "unit_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(unitWithProration = it, _json = json) - } + return Price( + unitWithProration = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_allocation" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(groupedAllocation = it, _json = json) - } + return Price( + groupedAllocation = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_with_prorated_minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(groupedWithProratedMinimum = it, _json = json) - } + return Price( + groupedWithProratedMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_with_metered_minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(groupedWithMeteredMinimum = it, _json = json) - } + return Price( + groupedWithMeteredMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "matrix_with_display_name" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(matrixWithDisplayName = it, _json = json) - } + return Price( + matrixWithDisplayName = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Price(bulkWithProration = it, _json = json) - } + return Price( + bulkWithProration = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(groupedTieredPackage = it, _json = json) - } + return Price( + groupedTieredPackage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "max_group_tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(maxGroupTieredPackage = it, _json = json) - } + return Price( + maxGroupTieredPackage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "scalable_matrix_with_unit_pricing" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(scalableMatrixWithUnitPricing = it, _json = json) - } + return Price( + scalableMatrixWithUnitPricing = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(scalableMatrixWithTieredPricing = it, _json = json) - } + return Price( + scalableMatrixWithTieredPricing = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "cumulative_grouped_bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(cumulativeGroupedBulk = it, _json = json) - } + return Price( + cumulativeGroupedBulk = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 ce2871a5..35ae5637 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 @@ -1408,294 +1408,256 @@ private constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingUnitPrice = it, _json = json) - } + return Body( + newFloatingUnitPrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingPackagePrice = it, _json = json) - } + return Body( + newFloatingPackagePrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingMatrixPrice = it, _json = json) - } + return Body( + newFloatingMatrixPrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "matrix_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body(newFloatingMatrixWithAllocationPrice = it, _json = json) - } + return Body( + newFloatingMatrixWithAllocationPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingTieredPrice = it, _json = json) - } + return Body( + newFloatingTieredPrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingTieredBpsPrice = it, _json = json) - } + return Body( + newFloatingTieredBpsPrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingBpsPrice = it, _json = json) - } + return Body( + newFloatingBpsPrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingBulkBpsPrice = it, _json = json) - } + return Body( + newFloatingBulkBpsPrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingBulkPrice = it, _json = json) - } + return Body( + newFloatingBulkPrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body(newFloatingThresholdTotalAmountPrice = it, _json = json) - } + return Body( + newFloatingThresholdTotalAmountPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingTieredPackagePrice = it, _json = json) - } + return Body( + newFloatingTieredPackagePrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "grouped_tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingGroupedTieredPrice = it, _json = json) - } + return Body( + newFloatingGroupedTieredPrice = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "max_group_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingMaxGroupTieredPackagePrice = it, - _json = json, - ) - } + return Body( + newFloatingMaxGroupTieredPackagePrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingTieredWithMinimumPrice = it, _json = json) - } + return Body( + newFloatingTieredWithMinimumPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingPackageWithAllocationPrice = it, - _json = json, - ) - } + return Body( + newFloatingPackageWithAllocationPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingTieredPackageWithMinimumPrice = it, - _json = json, - ) - } + return Body( + newFloatingTieredPackageWithMinimumPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_percent" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingUnitWithPercentPrice = it, _json = json) - } + return Body( + newFloatingUnitWithPercentPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body(newFloatingTieredWithProrationPrice = it, _json = json) - } + return Body( + newFloatingTieredWithProrationPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingUnitWithProrationPrice = it, _json = json) - } + return Body( + newFloatingUnitWithProrationPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_allocation" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingGroupedAllocationPrice = it, _json = json) - } + return Body( + newFloatingGroupedAllocationPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingGroupedWithProratedMinimumPrice = it, - _json = json, - ) - } + return Body( + newFloatingGroupedWithProratedMinimumPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingGroupedWithMeteredMinimumPrice = it, - _json = json, - ) - } + return Body( + newFloatingGroupedWithMeteredMinimumPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "matrix_with_display_name" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingMatrixWithDisplayNamePrice = it, - _json = json, - ) - } + return Body( + newFloatingMatrixWithDisplayNamePrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bulk_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingBulkWithProrationPrice = it, _json = json) - } + return Body( + newFloatingBulkWithProrationPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body(newFloatingGroupedTieredPackagePrice = it, _json = json) - } + return Body( + newFloatingGroupedTieredPackagePrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingScalableMatrixWithUnitPricingPrice = it, - _json = json, - ) - } + return Body( + newFloatingScalableMatrixWithUnitPricingPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingScalableMatrixWithTieredPricingPrice = it, - _json = json, - ) - } + return Body( + newFloatingScalableMatrixWithTieredPricingPrice = + deserialize( + node, + jacksonTypeRef< + NewFloatingScalableMatrixWithTieredPricingPrice + >(), + ), + _json = json, + ) } "cumulative_grouped_bulk" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingCumulativeGroupedBulkPrice = it, - _json = json, - ) - } + return Body( + newFloatingCumulativeGroupedBulkPrice = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } 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 2595aa18..737fc7f4 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 @@ -1943,56 +1943,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5247,28 +5239,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 721c288f..279e30f5 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 @@ -1931,56 +1931,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5235,28 +5227,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 02a23f6f..612a7721 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 @@ -4010,40 +4010,37 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + return Adjustment( + newPercentageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + return Adjustment( + newUsageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + return Adjustment( + newAmountDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } + return Adjustment( + newMinimum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } + return Adjustment( + newMaximum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -8736,304 +8733,247 @@ private constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnit = it, _json = json) - } + return Price( + newSubscriptionUnit = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionPackage = it, _json = json) - } + return Price( + newSubscriptionPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionMatrix = it, _json = json) - } + return Price( + newSubscriptionMatrix = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTiered = it, _json = json) - } + return Price( + newSubscriptionTiered = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredBps = it, _json = json) - } + return Price( + newSubscriptionTieredBps = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBps = it, _json = json) - } + return Price( + newSubscriptionBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulkBps = it, _json = json) - } + return Price( + newSubscriptionBulkBps = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulk = it, _json = json) - } + return Price( + newSubscriptionBulk = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionThresholdTotalAmount = it, - _json = json, - ) - } + return Price( + newSubscriptionThresholdTotalAmount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredPackage = it, _json = json) - } + return Price( + newSubscriptionTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTieredWithMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionTieredWithMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnitWithPercent = it, _json = json) - } + return Price( + newSubscriptionUnitWithPercent = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionPackageWithAllocation = it, - _json = json, - ) - } + return Price( + newSubscriptionPackageWithAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTierWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionTierWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionUnitWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionUnitWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedAllocation = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedWithProratedMinimum = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionGroupedWithProratedMinimumPrice + >(), + ), + _json = json, + ) } "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionBulkWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionBulkWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionScalableMatrixWithUnitPricing = it, - _json = json, - ) - } + return Price( + newSubscriptionScalableMatrixWithUnitPricing = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ), + _json = json, + ) } "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionScalableMatrixWithTieredPricing = it, - _json = json, - ) - } + return Price( + newSubscriptionScalableMatrixWithTieredPricing = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ), + _json = json, + ) } "cumulative_grouped_bulk" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionCumulativeGroupedBulk = it, - _json = json, - ) - } + return Price( + newSubscriptionCumulativeGroupedBulk = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "max_group_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionMaxGroupTieredPackage = it, - _json = json, - ) - } + return Price( + newSubscriptionMaxGroupTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithMeteredMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedWithMeteredMinimum = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionGroupedWithMeteredMinimumPrice + >(), + ), + _json = json, + ) } "matrix_with_display_name" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionMatrixWithDisplayName = it, - _json = json, - ) - } + return Price( + newSubscriptionMatrixWithDisplayName = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedTieredPackage = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } @@ -62044,40 +61984,37 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + return Adjustment( + newPercentageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + return Adjustment( + newUsageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + return Adjustment( + newAmountDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } + return Adjustment( + newMinimum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } + return Adjustment( + newMaximum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -66736,304 +66673,247 @@ private constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnit = it, _json = json) - } + return Price( + newSubscriptionUnit = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionPackage = it, _json = json) - } + return Price( + newSubscriptionPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionMatrix = it, _json = json) - } + return Price( + newSubscriptionMatrix = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTiered = it, _json = json) - } + return Price( + newSubscriptionTiered = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredBps = it, _json = json) - } + return Price( + newSubscriptionTieredBps = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBps = it, _json = json) - } + return Price( + newSubscriptionBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulkBps = it, _json = json) - } + return Price( + newSubscriptionBulkBps = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulk = it, _json = json) - } + return Price( + newSubscriptionBulk = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionThresholdTotalAmount = it, - _json = json, - ) - } + return Price( + newSubscriptionThresholdTotalAmount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredPackage = it, _json = json) - } + return Price( + newSubscriptionTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTieredWithMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionTieredWithMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnitWithPercent = it, _json = json) - } + return Price( + newSubscriptionUnitWithPercent = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionPackageWithAllocation = it, - _json = json, - ) - } + return Price( + newSubscriptionPackageWithAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTierWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionTierWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionUnitWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionUnitWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedAllocation = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedWithProratedMinimum = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionGroupedWithProratedMinimumPrice + >(), + ), + _json = json, + ) } "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionBulkWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionBulkWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionScalableMatrixWithUnitPricing = it, - _json = json, - ) - } + return Price( + newSubscriptionScalableMatrixWithUnitPricing = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ), + _json = json, + ) } "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionScalableMatrixWithTieredPricing = it, - _json = json, - ) - } + return Price( + newSubscriptionScalableMatrixWithTieredPricing = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ), + _json = json, + ) } "cumulative_grouped_bulk" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionCumulativeGroupedBulk = it, - _json = json, - ) - } + return Price( + newSubscriptionCumulativeGroupedBulk = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "max_group_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionMaxGroupTieredPackage = it, - _json = json, - ) - } + return Price( + newSubscriptionMaxGroupTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithMeteredMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedWithMeteredMinimum = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionGroupedWithMeteredMinimumPrice + >(), + ), + _json = json, + ) } "matrix_with_display_name" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionMatrixWithDisplayName = it, - _json = json, - ) - } + return Price( + newSubscriptionMatrixWithDisplayName = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedTieredPackage = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } 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 238ed484..a3ab48cc 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 @@ -1931,56 +1931,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5235,28 +5227,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 7b76e52d..659ec53c 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 @@ -2616,34 +2616,34 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Discount(amountDiscountCreationParams = it, _json = json) - } + return Discount( + amountDiscountCreationParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Discount( - percentageDiscountCreationParams = it, - _json = json, - ) - } + return Discount( + percentageDiscountCreationParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Discount(usageDiscountCreationParams = it, _json = json) - } + return Discount( + usageDiscountCreationParams = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } @@ -4842,311 +4842,264 @@ private constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingUnit = it, _json = json) - } + return Price( + newFloatingUnit = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingPackage = it, _json = json) - } + return Price( + newFloatingPackage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingMatrix = it, _json = json) - } + return Price( + newFloatingMatrix = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "matrix_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingMatrixWithAllocation = it, _json = json) - } + return Price( + newFloatingMatrixWithAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingTiered = it, _json = json) - } + return Price( + newFloatingTiered = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingTieredBps = it, _json = json) - } + return Price( + newFloatingTieredBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingBps = it, _json = json) - } + return Price( + newFloatingBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingBulkBps = it, _json = json) - } + return Price( + newFloatingBulkBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingBulk = it, _json = json) - } + return Price( + newFloatingBulk = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingThresholdTotalAmount = it, _json = json) - } + return Price( + newFloatingThresholdTotalAmount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingTieredPackage = it, _json = json) - } + return Price( + newFloatingTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingGroupedTiered = it, _json = json) - } + return Price( + newFloatingGroupedTiered = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "max_group_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingMaxGroupTieredPackage = it, - _json = json, - ) - } + return Price( + newFloatingMaxGroupTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingTieredWithMinimum = it, _json = json) - } + return Price( + newFloatingTieredWithMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingPackageWithAllocation = it, - _json = json, - ) - } + return Price( + newFloatingPackageWithAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingTieredPackageWithMinimum = it, - _json = json, - ) - } + return Price( + newFloatingTieredPackageWithMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingUnitWithPercent = it, _json = json) - } + return Price( + newFloatingUnitWithPercent = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingTieredWithProration = it, _json = json) - } + return Price( + newFloatingTieredWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingUnitWithProration = it, _json = json) - } + return Price( + newFloatingUnitWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingGroupedAllocation = it, _json = json) - } + return Price( + newFloatingGroupedAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingGroupedWithProratedMinimum = it, - _json = json, - ) - } + return Price( + newFloatingGroupedWithProratedMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingGroupedWithMeteredMinimum = it, - _json = json, - ) - } + return Price( + newFloatingGroupedWithMeteredMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "matrix_with_display_name" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingMatrixWithDisplayName = it, - _json = json, - ) - } + return Price( + newFloatingMatrixWithDisplayName = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingBulkWithProration = it, _json = json) - } + return Price( + newFloatingBulkWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingGroupedTieredPackage = it, _json = json) - } + return Price( + newFloatingGroupedTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingScalableMatrixWithUnitPricing = it, - _json = json, - ) - } + return Price( + newFloatingScalableMatrixWithUnitPricing = + deserialize( + node, + jacksonTypeRef< + NewFloatingScalableMatrixWithUnitPricingPrice + >(), + ), + _json = json, + ) } "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewFloatingScalableMatrixWithTieredPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingScalableMatrixWithTieredPricing = it, - _json = json, - ) - } + return Price( + newFloatingScalableMatrixWithTieredPricing = + deserialize( + node, + jacksonTypeRef< + NewFloatingScalableMatrixWithTieredPricingPrice + >(), + ), + _json = json, + ) } "cumulative_grouped_bulk" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingCumulativeGroupedBulk = it, - _json = json, - ) - } + return Price( + newFloatingCumulativeGroupedBulk = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } @@ -62271,40 +62224,37 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + return Adjustment( + newPercentageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + return Adjustment( + newUsageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + return Adjustment( + newAmountDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } + return Adjustment( + newMinimum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } + return Adjustment( + newMaximum = deserialize(node, jacksonTypeRef()), + _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 61ded1e1..6ca9556c 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 @@ -1941,56 +1941,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5245,28 +5237,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 56827f70..3ddc0603 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 @@ -3751,40 +3751,37 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + return Adjustment( + newPercentageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + return Adjustment( + newUsageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + return Adjustment( + newAmountDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } + return Adjustment( + newMinimum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } + return Adjustment( + newMaximum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -8477,304 +8474,247 @@ private constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnit = it, _json = json) - } + return Price( + newSubscriptionUnit = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionPackage = it, _json = json) - } + return Price( + newSubscriptionPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionMatrix = it, _json = json) - } + return Price( + newSubscriptionMatrix = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTiered = it, _json = json) - } + return Price( + newSubscriptionTiered = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredBps = it, _json = json) - } + return Price( + newSubscriptionTieredBps = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBps = it, _json = json) - } + return Price( + newSubscriptionBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulkBps = it, _json = json) - } + return Price( + newSubscriptionBulkBps = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulk = it, _json = json) - } + return Price( + newSubscriptionBulk = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionThresholdTotalAmount = it, - _json = json, - ) - } + return Price( + newSubscriptionThresholdTotalAmount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredPackage = it, _json = json) - } + return Price( + newSubscriptionTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTieredWithMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionTieredWithMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnitWithPercent = it, _json = json) - } + return Price( + newSubscriptionUnitWithPercent = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionPackageWithAllocation = it, - _json = json, - ) - } + return Price( + newSubscriptionPackageWithAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTierWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionTierWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionUnitWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionUnitWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedAllocation = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedWithProratedMinimum = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionGroupedWithProratedMinimumPrice + >(), + ), + _json = json, + ) } "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionBulkWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionBulkWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionScalableMatrixWithUnitPricing = it, - _json = json, - ) - } + return Price( + newSubscriptionScalableMatrixWithUnitPricing = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ), + _json = json, + ) } "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionScalableMatrixWithTieredPricing = it, - _json = json, - ) - } + return Price( + newSubscriptionScalableMatrixWithTieredPricing = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ), + _json = json, + ) } "cumulative_grouped_bulk" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionCumulativeGroupedBulk = it, - _json = json, - ) - } + return Price( + newSubscriptionCumulativeGroupedBulk = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "max_group_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionMaxGroupTieredPackage = it, - _json = json, - ) - } + return Price( + newSubscriptionMaxGroupTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithMeteredMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedWithMeteredMinimum = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionGroupedWithMeteredMinimumPrice + >(), + ), + _json = json, + ) } "matrix_with_display_name" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionMatrixWithDisplayName = it, - _json = json, - ) - } + return Price( + newSubscriptionMatrixWithDisplayName = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedTieredPackage = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } @@ -61701,40 +61641,37 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + return Adjustment( + newPercentageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + return Adjustment( + newUsageDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + return Adjustment( + newAmountDiscount = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } + return Adjustment( + newMinimum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } + return Adjustment( + newMaximum = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -66393,304 +66330,247 @@ private constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnit = it, _json = json) - } + return Price( + newSubscriptionUnit = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionPackage = it, _json = json) - } + return Price( + newSubscriptionPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionMatrix = it, _json = json) - } + return Price( + newSubscriptionMatrix = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTiered = it, _json = json) - } + return Price( + newSubscriptionTiered = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredBps = it, _json = json) - } + return Price( + newSubscriptionTieredBps = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBps = it, _json = json) - } + return Price( + newSubscriptionBps = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulkBps = it, _json = json) - } + return Price( + newSubscriptionBulkBps = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulk = it, _json = json) - } + return Price( + newSubscriptionBulk = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionThresholdTotalAmount = it, - _json = json, - ) - } + return Price( + newSubscriptionThresholdTotalAmount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredPackage = it, _json = json) - } + return Price( + newSubscriptionTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTieredWithMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionTieredWithMinimum = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnitWithPercent = it, _json = json) - } + return Price( + newSubscriptionUnitWithPercent = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionPackageWithAllocation = it, - _json = json, - ) - } + return Price( + newSubscriptionPackageWithAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTierWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionTierWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionUnitWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionUnitWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedAllocation = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedAllocation = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedWithProratedMinimum = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionGroupedWithProratedMinimumPrice + >(), + ), + _json = json, + ) } "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionBulkWithProration = it, - _json = json, - ) - } + return Price( + newSubscriptionBulkWithProration = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionScalableMatrixWithUnitPricing = it, - _json = json, - ) - } + return Price( + newSubscriptionScalableMatrixWithUnitPricing = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ), + _json = json, + ) } "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionScalableMatrixWithTieredPricing = it, - _json = json, - ) - } + return Price( + newSubscriptionScalableMatrixWithTieredPricing = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ), + _json = json, + ) } "cumulative_grouped_bulk" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionCumulativeGroupedBulk = it, - _json = json, - ) - } + return Price( + newSubscriptionCumulativeGroupedBulk = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "max_group_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionMaxGroupTieredPackage = it, - _json = json, - ) - } + return Price( + newSubscriptionMaxGroupTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithMeteredMinimum = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedWithMeteredMinimum = + deserialize( + node, + jacksonTypeRef< + NewSubscriptionGroupedWithMeteredMinimumPrice + >(), + ), + _json = json, + ) } "matrix_with_display_name" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionMatrixWithDisplayName = it, - _json = json, - ) - } + return Price( + newSubscriptionMatrixWithDisplayName = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "grouped_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedTieredPackage = it, - _json = json, - ) - } + return Price( + newSubscriptionGroupedTieredPackage = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } } 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 43a0718c..ccfae2c7 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 @@ -1942,56 +1942,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5246,28 +5238,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 8625be0b..445fce51 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 @@ -1939,56 +1939,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5243,28 +5235,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 fa96c019..ec2f23c1 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 @@ -1948,56 +1948,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5252,28 +5244,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 7de87f5d..26cf319d 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 @@ -1956,56 +1956,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5260,28 +5252,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 2565142b..f9acc535 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 @@ -1952,56 +1952,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5256,28 +5248,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 6f507f99..05279159 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 @@ -1948,56 +1948,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5252,28 +5244,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 3624f224..53e3efab 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 @@ -1939,56 +1939,48 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } + return Adjustment( + planPhaseUsageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } + return Adjustment( + planPhaseAmountDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } + return Adjustment( + planPhasePercentageDiscount = + deserialize( + node, + jacksonTypeRef(), + ), + _json = json, + ) } "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } + return Adjustment( + planPhaseMinimum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } + return Adjustment( + planPhaseMaximum = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } } @@ -5243,28 +5235,23 @@ private constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } + return DiscountInterval( + amount = deserialize(node, jacksonTypeRef()), + _json = json, + ) } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } + return DiscountInterval( + percentage = + deserialize(node, jacksonTypeRef()), + _json = json, + ) } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } + return DiscountInterval( + usage = deserialize(node, jacksonTypeRef()), + _json = json, + ) } } 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 new file mode 100644 index 00000000..dcc7b907 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt @@ -0,0 +1,81 @@ +package com.withorb.api.core + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.exc.MismatchedInputException +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.junitpioneer.jupiter.cartesian.CartesianTest + +internal class ObjectMappersTest { + + internal class ClassWithBooleanFieldPrefixedWithIs(private val isActive: JsonField) { + + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + } + + @Test + fun write_whenFieldPrefixedWithIs_keepsPrefix() { + val value = ClassWithBooleanFieldPrefixedWithIs(JsonField.of(true)) + + val json = jsonMapper().writeValueAsString(value) + + assertThat(json).isEqualTo("{\"is_active\":true}") + } + + internal class Class(@get:JsonProperty("field") @JsonProperty("field") val field: String) + + enum class ShapeTestCase(val value: Any, val kClass: KClass<*>) { + STRING("Hello World!", String::class), + BOOLEAN(true, Boolean::class), + FLOAT(3.14F, Float::class), + DOUBLE(3.14, Double::class), + INTEGER(42, Int::class), + LONG(42L, Long::class), + MAP(mapOf("property" to "value"), Map::class), + CLASS(Class("Hello World!"), Class::class), + LIST(listOf(1, 2, 3), List::class); + + companion object { + val VALID_CONVERSIONS = + listOf( + FLOAT to DOUBLE, + FLOAT to INTEGER, + FLOAT to LONG, + DOUBLE to FLOAT, + DOUBLE to INTEGER, + DOUBLE to LONG, + INTEGER to FLOAT, + INTEGER to DOUBLE, + INTEGER to LONG, + LONG to FLOAT, + LONG to DOUBLE, + LONG to INTEGER, + CLASS to MAP, + // These aren't actually valid, but coercion configs don't work for String until + // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 + // We currently test on v2.13.4. + BOOLEAN to STRING, + FLOAT to STRING, + DOUBLE to STRING, + INTEGER to STRING, + LONG to STRING, + ) + } + } + + @CartesianTest + fun read(@CartesianTest.Enum shape1: ShapeTestCase, @CartesianTest.Enum shape2: ShapeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(shape1.value) + + val e = catchThrowable { jsonMapper.readValue(json, shape2.kClass.java) } + + if (shape1 == shape2 || shape1 to shape2 in ShapeTestCase.VALID_CONVERSIONS) { + assertThat(e).isNull() + } else { + assertThat(e).isInstanceOf(MismatchedInputException::class.java) + } + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/SerializerTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/SerializerTest.kt deleted file mode 100644 index dae552e2..00000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/SerializerTest.kt +++ /dev/null @@ -1,97 +0,0 @@ -package com.withorb.api.core.http - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.withorb.api.core.* -import java.util.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SerializerTest { - @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) - class ClassWithBooleanFieldPrefixedWithIs - private constructor( - private val isActive: JsonField, - private val additionalProperties: Map, - ) { - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun isActive(): Boolean? = isActive.getNullable("is_active") - - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate() = apply { - if (!validated) { - isActive() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(isActive, additionalProperties) - } - return hashCode - } - - override fun toString() = - "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" - - companion object { - fun builder() = Builder() - } - - class Builder internal constructor() { - - private var isActive: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - @JsonProperty("is_active") - @ExcludeMissing - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs(isActive, additionalProperties.toImmutable()) - } - } - - @Test - fun serializeBooleanPrefixedWithIs() { - val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() - assertThat(jsonMapper().writeValueAsString(value)).isEqualTo("{\"is_active\":true}") - } -}